I have built a cross-platform C++ application that uses some external libraries (e.g. Boost, GLFW). My intention is to create an archive, for instance a .zip file, for each operating system so that the end user only has to extract this package in order to run the application. I am facing a problem related to dynamic linking of the libraries.
When I built the application in Linux, I use the -Wl,rpath
option to specify the run time library search path. On Windows, I can simply place all relevant .dll
files in the same folder as where the executable resides. Now on MacOS, I am facing the issue that the libraries are referred to by absolute paths. Those paths may be valid for my system, but not necessarily for the system of the user. I already found that I can change those paths to relative paths using install_name_tool
.
The remaining difficulty is that I have to change quite a lot of these references. Besides the references in the executable, some of the libraries have dependencies themselves which are also defined by absolute paths.
My question is: Is there an efficient and smart way to set relative paths instead of absolute paths for the libraries on MacOS?