static library problem

Started by
3 comments, last by Tonin 18 years, 5 months ago
Hi, I'm getting some odd behavior from my compiler/linker (DEV-C++ 4.9.9.2 if it matters), and thought some one of you could help me figure it out. I'm working on a static lib to provide nicer interfaces with the openGL functions. I had it working ok in an executable version (for easier testing and what not), I then added it in to my lib and it all compiled fine. Then I made a simple executable project to test the .a file, and got some funny linker errors; "C:/DEV-CPP5/lib/libKitty_lib2-1.a(view_mannager.o)(.text+0x182):view_mannager.cpp: undefined reference to `glFrustum@48'" and such. This only happens for GL functions that aren't used in the test program as well. For instance, if I make a call to glFrustum() in the test program then the error message above goes away and it links OK and runs properly. Any thoughts and/or explanations of this? Thanks, ~Andy
Advertisement
Bump. Any ideas anyone?
maybe its a problem with loading the opengl library. try linking your project to the lib and see what happens
Bring more Pain
Both my lib project and the test program are linked to the GL lib, and the test is linked to my lib as well so I think I've got that set properly. I can use GL functions and such fine in the test program (as long as all of the GL functions used in my lib are also called somewhere in the test prog), so I think the project settings are OK in that regard..

thanks,
~Andy
Ok, I figured it out after messing with it a bit more. The order of the libs that are linked in needed to be changed, putting my lib above the GL one. I'm not 100% sure, but I think this is because the linker only goes through each lib once and needs to know what to look for before it does it. That's why using the GL functions in the test program would fix it, since the linker goes through the test object file before anything else (I think).

I really should learn more about how the prepressecor/compiler/linker works.. [rolleyes]

~Andy

This topic is closed to new replies.

Advertisement