• 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
Re: Forcing a user library to load before system
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Forcing a user library to load before system


  • Subject: Re: Forcing a user library to load before system
  • From: Eric Albert <email@hidden>
  • Date: Wed, 16 Aug 2006 14:37:30 -0700

On Aug 16, 2006, at 2:11 PM, Wade Williams wrote:

I have a custom libz.a library (it includes the unzip functionality, which the system libz does not).

When I compile my application, I get:

/usr/bin/ld: Undefined symbols:
_unzClose
_unzCloseCurrentFile
_unzGetCurrentFileInfo

(i.e. all the functions that are in my libz and not the system libz)

I compile with (the -L and -l flags are bolded for emphasis and are correctly specified)
gcc version 4.0.1 (Apple Computer, Inc. build 5363)
/usr/libexec/gcc/i686-apple-darwin8/4.0.1/collect2 -dynamic -arch i386 -macosx_version_min 10.3 -multiply_defined suppress -weak_reference_mismatches non-weak -o ./objd/test_prog -lcrt1.o /usr/lib/gcc/i686-apple-darwin8/4.0.1/crt3.o -L../../lib/bind/ -L../../sdk/mac/lib -L../../sdk/mac/freetype/objs/.libs -L../../sdk/mac/antlr/lib/cpp/src -L../../sdk/mac/jpeg -L../../sdk/mac/gmp/.libs -L../../sdk/mac/HID Utilities Source/build/Deployment -L../../sdk/mac/FFB SDK/CFM_FFB/FFB headers -L/usr/lib/gcc/i686-apple-darwin8/4.0.1 -L/usr/lib/gcc/i686-apple-darwin8/4.0.1 -L/usr/lib/gcc/i686-apple-darwin8/4.0.1/../../.. ./objd/app.o ./objd/app_input.o ./objd/main.o ./objd/movie.o ./objd/msgqueue.o ./objd/player.o -lflight -lflight2 -lsound -lsound2 -lmeta -lnet -ljoystick -lcrypt -lwindow -lgui2 -lscene -lscene2 -lluabase -llua -lhash -lcampaign -lvector -lai -lutil -lmac -lz -lfreetype -lantlr -ljpeg -lgmp -lHIDUtilities -lmac_ffb -framework Carbon -framework OpenGL -framework System -framework AGL -framework DrawSprocket -framework IOKit -framework CoreFoundation -framework ForceFeedback -framework openal -framework libcurl -lstdc++ -lgcc_s.10.4 -lgcc -lSystem -F../../sdk/mac/openal/OpenAL-MacOSX/build/Deployment -F../../sdk/mac/curl/lib

Compiling with -whyload, the first reference to libz is this:

usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libz.dylib(deflate.o) loaded to resolve symbol: _deflate referenced from CoreGraphics

This leads me to believe that because CoreGraphics references libz, the system libz is being loaded and thus my library is never loaded.

How can I change this so that my libz is loaded first?

On Mac OS X, the linker looks through the entire search path for a dylib before looking back through the search path for a static library.  To change the behavior to check for a dylib and then a static library in the current path in the search list before going on to the next path (which I think is what you're looking for here), pass -search_paths_first to the linker.

Hope this helps,
Eric

 _______________________________________________
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

References: 
 >Forcing a user library to load before system (From: Wade Williams <email@hidden>)

  • Prev by Date: Forcing a user library to load before system
  • Next by Date: Forcing linking to occur on every build?
  • Previous by thread: Forcing a user library to load before system
  • Next by thread: Forcing linking to occur on every build?
  • Index(es):
    • Date
    • Thread