2

Below is my scenario,

  1. In my Application i had to make use of libopus library , i downloaded and install, compile --> install procedure is normal as its for any other open source library,

  2. I linked libopus.a with my application, the way i did is , by default it will get installed in /usr/local/lib, so i drag from there and add it to my application,

Worked fine and no error on my machine,

On Another machine, i was expecting it to be run smoothly as i included this library statically, but its throwing error as

dyld: Library not loaded: /usr/local/lib/libopus.0.dylib

so i concluded, libopus.a somehow including libopus.0.dylib also dynamically,

Now i am able ot add a copy phase in my build setting , so it will get copied in ../Framework folder

if i do otool -L libpus.a then it shows following result

otool -L /usr/local/lib/libopus.a
Archive : /usr/local/lib/libopus.a
/usr/local/lib/libopus.a(bands.o):
/usr/local/lib/libopus.a(celt.o):
/usr/local/lib/libopus.a(cwrs.o):
/usr/local/lib/libopus.a(entcode.o):
/usr/local/lib/libopus.a(entdec.o):
/usr/local/lib/libopus.a(entenc.o):
/usr/local/lib/libopus.a(repacketizer.o):

It doesn't show as its depend upon the dylib library Now my Question is
How to tell Application to look into this path first

I tried following option,

  1. install_name_tool but it seems it will work on other machine , so the user need to run this script NOT DEVELOPER,

  2. trying to set the some option in the xcode to set the RUNTIME Search path to locate that particular dylib but not getting succeed so far

Amitg2k12
  • 3,765
  • 10
  • 48
  • 97

1 Answers1

1

install_name_tool is run by the developer during the build process, not by the user.

If you're building the library, you should use libtool(1) with the option -install_name @rpath; otherwise, you can use install_name_tool(1) with -id @rpath to do the same thing on the dylib. Then, when you're building your application, set the "Runpath search paths" to the path where you will install the library.

Apple has some good documentation on this in their Mach-O Programming Topics and Dynamic Library Programming Topics.

一二三
  • 21,059
  • 11
  • 65
  • 74
  • thanks, i will try it out, BTW i was running out of time, and this issue got fixed, if i take libopus1.0.1 , in stead of 1.0.2 – Amitg2k12 Mar 28 '13 at 04:16