Linking FreeGlut Static Library to DLL

Basically I would like to link FreeGlut static library and include it in my project DLL.

I'm getting some undefined references as the linker seems to look for the DLL version of FreeGlut (which works).
Last edited on
Chances are you forgot to tell the compiler/linker where to find the static library.

How are you compiling the project? What is your compiler?
Hey George, it's via command line only, the project is a C++ DLL library and I'm using MinGW64.

Chances are you forgot to tell the compiler/linker where to find the static library.


both static and dynamic freeglut libs are in the same folder so the linker is finding it ok. It works when linking on the dynamic version.
How exactly do you link the library? If you use option -lfoo, then the linker will search all library directories – the default library directories as well as those added by -L option – for either libfoo.dll.a (shared lib) or libfoo.a (static lib). And it probably prefers the "shared" library, if both are available.

Instead of using -lfoo, you can enter /path/to/libfoo.a directly, to ensure that "static" library is linked.

(you can add -Wl,--trace to get more detailed output of which libraries are searched/used)

But, be aware that the "static" library you are trying to link can have some dependencies of its own! If so, then those dependencies have to be linked as well, or linking will fail with "undefined references" errors...
Last edited on
Ok thanks kigar64551, will try the trace option.
Topic archived. No new replies allowed.