On MacOS, *.dylib files have incorrect ID or install_name

134 views
Skip to first unread message

brat...@umbc.edu

unread,
Dec 20, 2020, 1:56:53 PM12/20/20
to dislin-users
Hello again,

[MacOS 10.14 Mojave, DISLIN 11.3, Fortran interface]
Now that I can run the demo for DISLIN on a Mac, I've started building DISLIN into my project, which revealed an issue with the dylib IDs (or install_names). I can run an executable, which is linked to DISLIN, directly from a terminal, but the same executable will not run when it is invoked from a Makefile (e.g. if the DISLIN executable is part of a test suite for the rest of the project, and is making diagnostic plots before other things run). I think it has something to do with the make creating another shell, and not having access to DYLD_LIBRARY_PATH. Anyway, it fails with:

dyld: Library not loaded: /usr/local/lib/libdislin_d.11.dylib
  Referenced from: /Users/username1/project-dir/test_exec
  Reason: image not found
make[1]: *** [alltests] Abort trap: 6
make: *** [tests] Error 2

The problem is that the symlink libdislin_d.11.dylib is not in /usr/local/lib—it is in /usr/local/dislin
If you run "otool -L /usr/local/dislin/libdislin_d.11.dylib", then it reveals that the ID in the actual dylib is "/usr/local/lib/libdislin_d.11.dylib", which is incorrect. The single-precision, double-precision, C++, and Java dylibs all have IDs with the prefix "/usr/local/lib" instead of the actual directory in which DISLIN is installed. (The Java dynamic library is named with a ".so" suffix, but it is still a Mach-O file like the others with a ".dylib" suffix)
I ran
install_name_tool -id /usr/local/dislin/libdislin.11.dylib libdislin.11.3.0.dylib
install_name_tool -id /usr/local/dislin/libdislin_d.11.dylib libdislin_d.11.3.0.dylib
and now I can run the test suite for the project, which will run the DISLIN executable without errors.

Actually, the ID for the Java dylib refers to the double-precision dylib, instead of the Java dylib, so that probably needs to be changed, too. I don't use Java, so I can't test this.

Another thing I noticed, is that after changing the IDs, I no longer seem to need DYLD_LIBRARY_PATH to point to anything.

I believe that the install_name_tool should be used to adjust the IDs to reflect the real installation prefix of DISLIN, for each of the four dylibs, as part of the installation script on Mac.

With much appreciation, especially for supporting one of the few libraries that can plot directly from Fortran,
Anthony Bratt

Helmut Michels

unread,
Dec 22, 2020, 5:53:10 AM12/22/20
to dislin-users
Dear Anthony,

thank you for the hint. I will correct the install names on Mac OSX with the next upgrade.

With best regards,

Helmut
Reply all
Reply to author
Forward
0 new messages