Sign in to follow this  

Project wants to link to static libraries of a static library used by it

This topic is 683 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

Hi everyone!

 

I have been trying some openGL-Code lately and got some weird behavior when building one of my test projects.

 

Firstly, I use GLEW in a static library, which holds all the code for wrapping different graphics API. While this library and test-projects defined in the same CMakeLists.txt build and link correctly, external projects which use the library fail at the linker stage.

 

Linking to the renderlib from an external project, which only links to that renderlib and nothing else, makes the linker complain that it can't find glew32.lib. Which of course is true, everything that needs any code from GLEW should be statically linked in the renderlibs .lib-file.

 

Could it probably be that the compiler strips some static linkage of the GLEW-lib because of some optimization and then needs any program using the renderlib to link to glew for itself? Or am I probably just missing something here and this is completely normal behavior?

 

Any help is much appreciated!

Share this post


Link to post
Share on other sites
It's very easy to get things stripped from a .lib file. I'd pursue that as the most likely culprit.


In VS2013 for example if you go to Project -> Properties -> Configuration Properties -> Librarian -> Link Library Dependencies and set the option to Yes it might hopefully resolve this, assuming I understand correctly.


There are ways to manually force your linker to include symbols in the .lib but I think that's pretty heavy-handed and probably not the first choice.

Share this post


Link to post
Share on other sites

Thanks for the reply! This flag is exactly what I needed. However, after doing some research, it doesn't seem possible to set using CMake without using some very ugly hacks.

However, it turns out that you can compile GLEW just with a few .h./.c files yourself, and someone of my team came up with a CMakeLists.txt doing exactly that, solving the problem.

Share this post


Link to post
Share on other sites

This topic is 683 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.

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