How to use dylib in Mac OS X (C++)

After reading the link that Justin provided, I was successfully able to use the @executable_path token to change my dylib install_name to point to the same dir where my executable is located. @executable_path Absolute paths are annoying. Sometimes you want to embed a framework into an application instead of having to install the framework into … Read more

dyld: Library not loaded: ….. How to correctly tell GCC Compiler where to find another static library?

I guess I’ll use this question to write a canonical answer for all “image not found” issues. 1. The issue Let’s start with a minimal setup consisting of a main binary and a library, like so: main.c: #include <stdio.h> extern int f(void); int main(void) { printf(“%u\n”, f()); return 0; } xyz.c: int f(void) { return … Read more

Conflict between dynamic linking priority in OSX?

I experienced similar problem while using OpenCV in MacOS El Capitan. Solved the problem using the solution in the link Solution is to delete some dlylibs in the /usr/local/lib directory and create symbolic links to related files /System/Library/Frameworks/ImageIO.framework/Resources/ cd /usr/local/lib rm libgif.dylib ln -s /System/Library/Frameworks/ImageIO.framework/Resources/libGIF.dylib libGIF.dylib rm libjpeg.dylib ln -s /System/Library/Frameworks/ImageIO.framework/Resources/libJPEG.dylib libJPEG.dylib rm libtiff.dylib ln … Read more

dyld: Library not loaded … Reason: Image not found

Find all the boost libraries (where exefile is the name of your executable): $ otool -L exefile exefile: @executable_path/libboost_something.dylib (compatibility version 0.7.0, current version 0.7.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0) and for each libboost_xxx.dylib, do: $ install_name_tool -change @executable_path/libboost_something.dylib /opt/local/lib/libboost_something.dylib exefile and finally verify using otool … Read more