I compiled a program by statically linking external libraries on XCode. However, I am having errors on how to dynamically link those libraries.
For Static Linking, I did 1. Went to Build Phases, Link Binary with Libraries, Chose the static .a libraries 2. Went to Build settings and modified the Header Search path to the header files directory 3. Modified the Library search path to the static library directory.
I compiled the program and it works.
Then I am trying to dynamic linking 1. Went to Build Phases, Link Binary with Libraries, removed the static .a libraries and added the .dylib libraries (they are in the same directory) 2. Tried compiling - But I am getting 'Library not loaded:@loader_path/(lib name).dylib.. Reason: image not found'.
Am I missing one of the paths? What am I doing wrong?
Solved it by adding DYLD_LIBRARY_PATH environment variable.
Created an environment variable by (menu) Product -> Scheme -> Edit Scheme. Under 'Environment Variables', created a 'DYLD_LIBRARY_PATH' variable and pointed it to my dynamic library directory.
It works :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.