User forums > Help

Problem when linking (GCC)

<< < (2/2)

KK:
Then maybe you can tell me if I have a chance to put them where I wanted them: I got two targets, called Debug and Release. Both need to link opengl32, glu32, glfw and glf. Debug also has to link cavernd, while Release needs cavern. These are Debug and Release versions of a library I wrote that uses the other four libraries above. Now as it works I'm linking it before the other four, when it didn't work I linked it as the last library. Is it because of cavern using the other four that I have to link it first?

Kolja

mandrav:
I will answer you in a generic way:

Say an app needs libFoo.a and libBar.a to link.
The point is that if libBar.a references symbols from libFoo.a, you must link libBar.a before libFoo.a.

Google for it if you need more technical info on why this happens.

For your app, put in the project's options the common libs (opengl32, glu32, etc) and put cavern* in each target. Then set the linker options policy for your targets to "Prepend target options to project options". This will cause cavern to be listed before opengl32 and the rest, so it will work.

--- Quote ---Is it because of cavern using the other four that I have to link it first?
--- End quote ---

Exactly. Whichever unresolved symbols the linker encounters in cavern, it will try to resolve them in the following libs.

HTH,
Yiannis.

KK:
Thanks again, now it makes sense. I had thought it was the other way around, first linking the basic libraries and then the ones using the first.

Kolja

Navigation

[0] Message Index

[*] Previous page

Go to full version