User forums > Help

Linking multiple chain-dependent static libs

(1/3) > >>

Digited:
I have a nightmare-like problem with static libs' linking
windows xp sp2 pro, last night build of c::b, mingw-gcc 3.4.5

There's a console app (.exe) and a static lib, which uses OpenGL. Console app links my static lib and win&opengl static libs from gcc's lib dir, linking is successfull. (libwinmm, libgdi32, libopengl32, libglu32)

Successfull linking finishes, when I try to link my other static libs, also compiled with mingw - and no matter what lib - jpeg or glew or parts of my static lib (I made 4 from 1 to build changes faster). Linker doesn't find anything in cross-dependent static libs, no matter they are all linked in app' options and all directories are added...

All static libs are compiled and found at linking stage, but not implementations... Also there are problems with linking default libs like winmm and opengl - also undefined references, no matter they all linked successfully when I had only one static lib...

What is happening?

stahta01:
The order you list the Libraries in matter; I have been up to long for me to remember which goes first for sure.
But, I think if Lib1 calls code in Lib2 then Lib1 must be listed before Lib2 in the Library list.

I normally Google for the missing reference and see which library it is in.

Note, you did export the stuff from your library right?

Tim S

Digited:
Linkage ordering is right, for sure.

What and how should I export from the static library?..

Again, situation:
1. app exe + static lib which uses opengl. app links static lib and libwinmm, libopengl32 and libglu32. All works.
2. app exe + static lib 1 + static lib 2 + static lib 3. 3 libs are made from one lib to build changes faster. app links all 3 libs and libwinmm, libopengl32 and libglu32. Nothing links, opengl too! What can it be?..

linkage order: libwinmm, libopengl32, libglu32, sl3, sl2, sl1 (as they depend on each other). Just absolutely nothing is linking, like there's no libs! They are, and paths are ok in 1 and 2, because bin dir is still the same...

stahta01:
Look up the keywords __declspec(dllexport)

I found this with Google
http://www.geocities.com/yongweiwu/stdcall.htm
http://sig9.com/node/35

I am far from expert on this, I suggest reading this and other sources.

From what I read you don't need to use __declspec(dllexport) on static Libraries. Note, I have had to remove this code to get code to compile and link as static Library for Code::Blocks in the past.

In other words, look at the missing methods and see if they are prefixed by an Macro that is defined as __declspec(dllexport) or __declspec(dllimport).

Tim S

stahta01:

--- Quote from: Digited on September 25, 2007, 10:26:10 am ---linkage order: libwinmm, libopengl32, libglu32, sl3, sl2, sl1 (as they depend on each other). Just absolutely nothing is linking, like there's no libs! They are, and paths are ok in 1 and 2, because bin dir is still the same...

--- End quote ---

Base your answer on just the first 3 missing references.
The missing references are defined in which library?
The missing references are being called from what library or file?

Tim S

Navigation

[0] Message Index

[#] Next page

Go to full version