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

Started by
1 comment, last by mind in a box 8 years, 2 months ago

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!

Advertisement
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.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

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.

This topic is closed to new replies.

Advertisement