• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Linking and cross-referenced static libraries
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Linking and cross-referenced static libraries


  • Subject: Linking and cross-referenced static libraries
  • From: Adam Zegelin <email@hidden>
  • Date: Fri, 13 Jul 2007 13:35:36 +1000

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
—
Adam Zegelin


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Linking and cross-referenced static libraries
      • From: Rush Manbert <email@hidden>
  • Prev by Date: Embedding frameworks problem
  • Next by Date: Re: Embedding frameworks problem
  • Previous by thread: Re: Embedding frameworks problem
  • Next by thread: Re: Linking and cross-referenced static libraries
  • Index(es):
    • Date
    • Thread