| Hi,
I'm currently working on porting a Win32 project that splits up individual components into static libraries, all of which are linked together into the final executable. Each static library references symbols defined in the other components. The Win32 version (which is compiled with MSVC 2005 via perl scripts) links each separate component into the final executable in an arbitrary order (atm, i think its alphabetical). MSVC's linker has no complaints about this and resolves all the external symbols in each static library correctly. However the same project compiled with Xcode (or gcc directly via the command line) results in errors from ld. It complains about the link order, which, while I have found the order required, is confusing to me. Is there anyway to tell ld to ignore the order of the libraries?
As an example of the problems I'm having I created a simple test Xcode project which shows the problem...
3 targets: - 1 executable - 2 static libraries (lib1 and lib2)
lib1 contains 2 functions lib1FuncA() which calls lib2FuncB() lib1FuncB() which prints "Hello from lib1"
lib2 contains 2 functions lib2FuncA() which calls lib1FuncB() lib2FuncB() which prints "Hello from lib2" The executable calls one of the functions lib1FuncA() or lib2FuncA()
If the executable calls lib1FuncA() lib1 must be linked before lib2 otherwise ld complains about the lib2 functions being undefined. If the executable calls lib2FuncA() lib2 must be linked before lib1 otherwise ld complains about the lib1 functions being undefined.
Thanks, Adam |