View Full Version : Problem with gltReadTGABits

06-25-2011, 01:42 PM

So I have been working through the OpenGL superbible and I have just started learning how to texture objects, but I've hit a problem. When I try to run my code I get the following error:

Undefined symbols for architecture x86_64:
"gltReadTGABits(char const*, int*, int*, int*, unsigned int*)", referenced from:
LoadTGATexture(char const*, unsigned int, unsigned int, unsigned int) in texturedPyramid.o
(maybe you meant: __Z14gltReadTGABitsPKcPiS1_S1_PjPa)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The problem isn't with my code as I get the same error when I try compile the source code for the example programs. After 2 hours of googling I am still completely clueless so hopefully someone here cam explain what the problem might be.

Thanks in advance.

Alfonse Reinheart
06-25-2011, 02:52 PM
Did you link to the "glt" library that comes with the OpenGL Superbible? If you didn't, then you can't use "gltReadTGABits".

06-25-2011, 03:32 PM
I believe so. I followed the instructions in the book, linking to gltools/include in the header search path, and copying the libGLTools.a file into the frameworks folder. I haven't had any problems with gltools method calls in previous chapters.

06-26-2011, 05:21 AM
Okay I have found a temporary solution. I have copied the gltReadTGAbits function from gltools.cpp into my source code and renamed it ReadTGAbits and my code now works. Still not sure why it didn't work in the first place though?

06-26-2011, 12:01 PM
I hit the same problem last night and did what you suggested above to workaround the problem to get it working. I also had to copy the TGAHEADER struct from GLTools.cpp into Pyramid.cpp

It seems to me that libGLTools.a that is provided is outdated. Perhaps rebuilding that might help though I do not know how to do that. If any one has success, please post to this thread

07-26-2011, 11:31 PM
Simply link to gltools/src as you previously linking to gltools/include in the header search path

07-26-2011, 11:42 PM
Oh and andd this line of code to you c++ file:

#include <GLTools.cpp>

07-28-2011, 07:59 PM
I encountered the same problem with u
I solved it by recompiling the libGTLTools.a file (I am using mac os x system)
hope this can help u

07-31-2011, 10:53 AM
I tried recompiling libGLTools.a - I am also using max os x

I opened a terminal and did the following:
$ cd <path_to source_files>
$ g++ -c *.cpp -I../include
$ g++ -c glew.c - I../include
$ ar rcs libGLTools.a *.o

This did not help either.

If you could provide the details of how you did the recompile, that would be very useful to me.