beardsvibe / buildfox

Minimalistic Ninja generator
MIT License
50 stars 8 forks source link

OS X shared libs install name #139

Closed jimon closed 8 years ago

jimon commented 8 years ago

While working on #93 I figured out that on OS X we are building shared libs somewhat incorrect. If we don't specify install name while building the shared libs, so by default ld will take the name provided in -o as install_name (wtf srsly). It makes it to set whole build/bin_debug/libname.soas install_name, which limits where executable can look for libs, because executable will look into $cwd/$install_name, which in the end makes an executable which can only be started from specific cwd (facepalm).

To fix it we need to set install_name with @rpath prefix, and than set rpath in executable to be something like @executable_path, so dyld will actually look in the place where executable is located regardless of cwd. See https://github.com/beardsvibe/buildfox/commit/9591e3a17add2d928430599f551936c2d714fc91

PS. On windows PE loader always look for dlls in executable folder, regardless of cwd, why OS X is that different? :(

jimon commented 8 years ago

The main problem here IMHO that buildfox currently doesn't have tools to extract filename and set install_name by it's own. Otherwise we could just fix core definitions and done :)