• 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
Linker issue: static lib which uses a dylib
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Linker issue: static lib which uses a dylib


  • Subject: Linker issue: static lib which uses a dylib
  • From: "Simon Raisin" <email@hidden>
  • Date: Tue, 14 Aug 2007 21:46:10 -0400

Ok, here is a fun one.

Let's jump right into pseudo code:

// App
#include "HeaderFromStaticLibrary.h"
main()
{
  some_method_in_static_library();
}

// Static Library
#include " HeaderFromDynamicLibrary.h"
some_method_in_static_library()
{
  some_method_in_dynamic_library();
}

// Dynamic Library
some_method_in_dynamic_library()
{
  // do something...
}

My app links against both libraries, but the link fails.  The failure is, "undefined symbol for some_method_in_static_library() in main()".  If I remove the dependency of the dylib from the static lib, the linker error goes away.  So the error really means that the linker can't find some_method_in_dynamic_library() that is being called from some_method_in_static_library().

My dynamic library gets installed into /user/local/lib and I've used 'otool -L' to verify that the right path is embedded into the dylib.  And of course the dylib *is* installed into /usr/local/lib.

I'm not an Xcode wizard, so I'm a little perplexed as to how I might get around this.

Here is the linker output (sorry for the spew):


Checking Dependencies

CompileC build/DylibTester.build/Debug/DylibTester.build/Objects-normal/i386/MyApp.o /Users/cxt/dev/DylibTester/MyApp.mm normal i386 objective-c++ com.apple.compilers.gcc.4_0
    cd /Users/cxt/dev/DylibTester
    /Developer/usr/bin/gcc-4.0 -x objective-c++ -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -fvisibility-inlines-hidden -mfix-and-continue -mmacosx-version-min= 10.5 -gdwarf-2 -I/Users/cxt/dev/DylibTester/build/DylibTester.build/Debug/DylibTester.build/DylibTester.hmap -F/Users/cxt/dev/DylibTester/build/Debug -I/Users/cxt/dev/DylibTester/build/Debug/include -I/Users/cxt/dev/DylibTester/build/DylibTester.build/Debug/DylibTester.build/DerivedSources -isysroot /Developer/SDKs/MacOSX10.5.sdk -include /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/DylibTester_Prefix-fzrceookoczuapbgfanwtszqfrph/DylibTester_Prefix.pch -c /Users/cxt/dev/DylibTester/MyApp.mm -o /Users/cxt/dev/DylibTester/build/DylibTester.build/Debug/DylibTester.build/Objects-normal/i386/MyApp.o

Ld /Users/cxt/dev/DylibTester/build/Debug/DylibTester.app/Contents/MacOS/DylibTester normal i386
    cd /Users/cxt/dev/DylibTester
    /Developer/usr/bin/g++-4.0 -o /Users/cxt/dev/DylibTester/build/Debug/DylibTester.app/Contents/MacOS/DylibTester -L/Users/cxt/dev/DylibTester/build/Debug -F/Users/cxt/dev/DylibTester/build/Debug -filelist /Users/cxt/dev/DylibTester/build/DylibTester.build/Debug/DylibTester.build/Objects-normal/i386/DylibTester.LinkFileList -framework Cocoa -arch i386 -mmacosx-version-min= 10.5 -lMyDylib -isysroot /Developer/SDKs/MacOSX10.5.sdk
Undefined symbols:
  "addTwoNums(int, int)", referenced from:
      -[MyApp awakeFromNib] in MyApp.o
ld64-74.4 failed: symbol(s) not found
collect2: ld returned 1 exit status
 _______________________________________________
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: Linker issue: static lib which uses a dylib
      • From: "Simon Raisin" <email@hidden>
  • Prev by Date: Re: How to generate preprocessed intermediate files?
  • Next by Date: my problems with X-code "build"
  • Previous by thread: Re: How to generate preprocessed intermediate files?
  • Next by thread: Re: Linker issue: static lib which uses a dylib
  • Index(es):
    • Date
    • Thread