• 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: dylib library from
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dylib library from


  • Subject: Re: dylib library from
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Tue, 18 Mar 2008 10:02:23 +0100


Le 18 mars 08 à 05:49, David Hinz a écrit :

What are the steps necessary to use a standard dynamic C++ library from one project in another project?

I created a dylib library in one project and then dragged the .h file and dylib library from that project to another project.  The application links with the library but when I try to run it I get the following error:

dyld: Library not loaded: /usr/local/lib/libXYZ.dylib
  Referenced from: /Users/dhinz/Projects/TestCode/TestRandomFile/build/Debug/TestRandomFile
  Reason: image not found

If I copy the library into /usr/local/lib then the program runs without error.  I'm sure there is a way to run without copying the library into /usr/local/lib but I haven't been able to figure it out from the documentation.

The library search paths look correct.  Are they used for compiling and while running?

Where is this documented?

Is it possible to create a framework with the dylib and .h file?

When you create your dylib file, you have to define the install path. by default the install path is /usr/lib for a Shared library and /Library/Framework for a framework (INSTALL_PATH build setting).
Then when you link an other binary to this dylib, it save this "install path" and then use it to locate you dylib.
You can change the install path of a dylib and the path used to reference it in an executable by using install_name_tool
If you want to use a path relative to an executable, use the @executable_path keyword in your install path. For exemple, if you want to create an executable that will use a library in the same directory, create your dylib with @executable_path/. as install name.
If you want to use a path relative to a framework (that require it for example), use the @loader_path keyword.

There is some details in "Loading code at runtime" (http://developer.apple.com/documentation/DeveloperTools/Conceptual/MachOTopics/Articles/loading_code.html)

 _______________________________________________
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: dylib library from
      • From: Dmitry Markman <email@hidden>
References: 
 >dylib library from (From: David Hinz <email@hidden>)

  • Prev by Date: Re: Xcode 3.0 crashes and 32-bit mode
  • Next by Date: Re: Framework Links Work OK in 10.5 and 10.4, Crash in 10.3
  • Previous by thread: dylib library from
  • Next by thread: Re: dylib library from
  • Index(es):
    • Date
    • Thread