Sign in to follow this  
Tonin

static library problem

Recommended Posts

Tonin    148
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

Share this post


Link to post
Share on other sites
Tonin    148
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

Share this post


Link to post
Share on other sites
Tonin    148
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this