Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: Valento92 on April 07, 2015, 02:40:37 pm

Title: Static libraries' double dependency and undefined references
Post by: Valento92 on April 07, 2015, 02:40:37 pm
Hi guys, this is my first post here! Glad to meet you all! :)

So, I have run into the following situation: lib A with function func1, and lib B with func2 which makes use of lib A's func1. Both are static libraries, and compiled fine. When I try using lib B's func2 in my test project, it throws undefined reference to lib A's func1 which lib B's func2 depends on, BUT I have include/lib directories as well as linker settings (libA.a, libB.a, etc) correctly set up.
This is a sample project: http://www.4shared.com/zip/EjwFZnVkba/doubleDependency.html

Of course this is just to illustrate the situation. In my real project, I am following a tutorial series to create a game engine with SDL/GLEW/OpenGL using, of course, Code::Blocks as my IDE. I have my game engine lib with a lot of functions and classes heavily using GLEW and SDL, and it compiles fine, but when I include this engine lib (it's just Engine.a file, so figure the simplicity) and set up my linker flags, it won't compile. My game project gives my GLEW undefined reference errors.

I've tried very hard trying different setups, but it just won't compile... I didn't want to switch to VS, I'd like to solve it with C::B, that's why I'm seeking help.  :(

I appreciate all your help.
Title: Re: Static libraries' double dependency and undefined references
Post by: Valento92 on April 07, 2015, 03:06:52 pm
Hey guys, I got it working! For some reason I had to add my Engine.a BEFORE all other flags under linker settings. It's much counter-intuitive to have to add the lib BEFORE its dependencies, but that solved my problem.

I wish you all a wonderful day! :)