osx - how to make Xcode project with homebrew libraries portable? -


i have installed freetype on mac using brew. code on mac works fine, when try run project on other mac below mentioned linking error.

dyld: library not loaded: /usr/local/opt/freetype/lib/libfreetype.6.dylib referenced from: /users/ashutosh/library/developer/xcode/deriveddata/instrumentchamp-  etytleaabhxmokadgrjzbgtmwxfl/build/products/debug/instrumentchamp.app/contents/macos/instrumentchamp reason: image not found (lldb)  

all library directories , include directories of freetype included in project's '$srcroot/' directory when try run code on other mac.

the path see in linking error library brew had installed freetype in mac created project.

/usr/local/opt/freetype/lib/libfreetype.6.dylib 

i have copied lib/ include/ directories needed project's home folder.
and have set library , include paths in xcode.

what missing here? else have make code portable on other mac. got project run on other mac installing brew, want without need install brew.

ps: had install freetype using brew, couldn't compile .dylib freetype 32bit processor, 64bit copy of .dylib giving me error such 'wrong architecture!'

the basic idea getting @ in comments os x pretty stupid searches libraries, use same absolute path used during compilation resolve them @ run-time.

usually when want deploy/distribute application different machine 1 built it, include libraries install package/bundle. want them use path relative application @ run-time, install_name_tool -change allows replace nasty absolute path relative.

hope makes sense, apple makes easy use system-wide frameworks on os x, custom libraries not much. if compile using system-wide framework, /system/library/frameworks/... universally available on os x installs (given same target release version).


solve problem, following:

install_name_tool -change /usr/local/opt/freetype/lib/libfreetype.6.dylib @executable_path/lib/libfreetype.6.dylib <executable_name_here>

then stop looking libfreetype.6.dylib in location when compiled software, , instead search relative executable's location @ run-time (in case, in sub-directory lib/).


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -