OpenGL Linker error when running source code from superbible third edition.

This topic is 3603 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hey, I hope I have put this question in the right forum. I'm trying to run this code from the superbible, using Dev-C++ 5. All previous code from the book upto now has compiled fine, but this one in particular is giving me a linker error. The program declares a data type that is defined in a seperate header file GLTools.h. I have added the file to my project, the #inlcude in the .cpp file looks as follows:
#include <cmath>
#include <cstdlib>
#include <iostream>

#include <gl/glut.h>
//#include "OpenGLSB.h"
#include <stdlib.h>


The header file (gltools.h )with the function which is not being identified:
// vector functions in VectorMath.c

void gltTransformPoint(const GLTVector3 vSrcPoint, const GLTMatrix mMatrix, GLTVector3 vPointOut);

void gltAddVectors(const GLTVector3 vFirst, const GLTVector3 vSecond, GLTVector3 vResult);
void gltSubtractVectors(const GLTVector3 vFirst, const GLTVector3 vSecond, GLTVector3 vResult);
void gltScaleVector(GLTVector3 vVector, const GLfloat fScale);
GLfloat gltGetVectorLengthSqrd(const GLTVector3 vVector);
GLfloat gltGetVectorLength(const GLTVector3 vVector);
void gltNormalizeVector(GLTVector3 vNormal);
void gltGetNormalVector(const GLTVector3 vP1, const GLTVector3 vP2, const GLTVector3 vP3, GLTVector3 vNormal);
void gltCopyVector(const GLTVector3 vSource, GLTVector3 vDest);
GLfloat gltVectorDotProduct(const GLTVector3 u, const GLTVector3 v);
void gltVectorCrossProduct(const GLTVector3 vU, const GLTVector3 vV, GLTVector3 vResult);


I guess I'm somehow not linking the header file correctly, but apart from including the gltools.h in my main file I don't know what else I can do. Any help with this problem will be appreciated! thanks

Share on other sites
What's the exact error you get? Have you added the source file containing the implementation of the functions in gltools.h to the project?

Share on other sites
It would help if you posted the actual linker error...

Share on other sites
Ok, the linker error only says:

[Linker Error] undefined reference to 'gltTransformPoint'
[Linker Error] undefined reference to 'gltTransformPoint'
[Linker Error] undefined reference to 'gltRotationMatrix'

There are no line references.

Quote:
 Have you added the source file containing the implementation of the functions in gltools.h to the project?

I went back to gltools.h, and at the bottom found the text:

/////////////////////////////////////////////////////////////////////////////////////
// Functions, need to be linked to your program. Source file for function is given

After changing the extension to cpp and adding to project, i get a set of different errors.

LoadTGA.cpp: In function GLbyte* gltLoadTGA(const char*, GLint*, GLint*, GLint*, GLenum*)':
LoadTGA.cpp:48: error: GL_BGR_EXT' undeclared (first use this function)
LoadTGA.cpp:48: error: (Each undeclared identifier is reported only once for each function it appears in.)

LoadTGA.cpp:84: error: invalid conversion from void*' to GLbyte*'
LoadTGA.cpp:105: error: `GL_BGRA_EXT' undeclared (first use this function)

How would I add the source files of the implementations? I noticed that gltools.h not only references LoadTGA.c, but also a set of different files like vectorMath.c that I quoted in my first post. Would I need to add all those files to my project?? or is there a quicker way, they all happen to be located in the same folder in the cd that came with the book.

1. 1
2. 2
Rutin
20
3. 3
4. 4
5. 5
frob
13

• 9
• 14
• 10
• 9
• 17
• Forum Statistics

• Total Topics
632601
• Total Posts
3007359

×