Jump to content
  • Advertisement
Sign in to follow this  
Mr_Od86

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.

If you intended to correct an error in the post then please contact us.

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 "GLTools.h"  //The header file
//#include "OpenGLSB.h"
#include <stdlib.h>

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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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
// LoadTGA.c

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!