CMake issue: binary (needed during build) links againts /opt/local/lib/foo.dylib

Joshua Root jmr at macports.org
Thu Sep 29 22:51:07 PDT 2016


On 2016-9-30 12:18 , Ryan Schmidt wrote:
>
>> On Sep 29, 2016, at 8:30 PM, Mojca Miklavec <mojca at macports.org> wrote:
>>
>> Hi,
>>
>> Under
>> https://svn.macports.org/repository/macports/users/mojca/ports/tex/miktex
>>
>> I have a preliminary port for MikTeX with the following problem:
>>    https://sourceforge.net/p/miktex/bugs/2485/
>>
>> The developer was fast in fixing many issues, but this one is
>> something that probably doesn't affect linux users, so he cannot
>> easily test.
>>
>> The problem is that a binary that is needed as part of the build
>> procedure gets built and links against /opt/local/lib/something.dylib.
>> Usually that would be desired, but in this case the library
>> something.dylib cannot be found before the package is installed. The
>> build system should thus first give the libraries the id of the build
>> path and only fix that at the very end of the build procedure, but
>> it's not entirely clear to me how to properly achieve that.
>>
>> Does anyone with a deeper understanding of CMake build system have any
>> idea what to fix?
>
> The solution is to set DYLD_FALLBACK_LIBRARY_PATH to the path where the library can be found at build time. Set that environment variable at the time that you want to run the program that needs the library.
>
> I don't know how to accomplish that in cmake specifically.

Actually, this is a valid situation for using DYLD_LIBRARY_PATH. If you 
use DYLD_FALLBACK_LIBRARY_PATH, and there is an older version of the 
library installed in ${prefix}/lib, the linker will find that first and 
run the executable with it instead of the new version in the build dir.

- Josh


More information about the macports-dev mailing list