Reputation: 193
I've got a compiled program mybinary
that fails immediately with "image not found" when I try to run it. It isn't the path to the missing dynamic library that's the problem, it's that it needs to look at the library name that doesn't include the version number.
At execution of mybinary
, I get this (edited for brevity):
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicuuc.68.dylib
Reason: image not found
Running otool -L mybinary
shows this (also edited for brevity):
/usr/local/opt/icu4c/lib/libicuuc.68.dylib
I want it to look at libicuuc.dylib
without the ".68". An ls -1
shows it exists:
/usr/local/opt/icu4c/lib/libicuuc.69.1.dylib
/usr/local/opt/icu4c/lib/libicuuc.69.dylib
/usr/local/opt/icu4c/lib/libicuuc.a
/usr/local/opt/icu4c/lib/libicuuc.dylib
Because the version referenced in mybinary
is 68 (lower than 69, thus preventing Incompatible library version
), I can fix mybinary
by executing the following:
sudo install_name_tool -change /usr/local/opt/icu4c/lib/libicuuc.68.dylib /usr/local/opt/icu4c/lib/libicuuc.dylib mybinary
Now, mybinary
launches just fine.
The goal, though, is to modify the Makefile
for mybinary
so that it will link to libicuuc.dylib
.
How can I do this?
mybinary
is deployed in a tar file to end users, and they are more likely to have a more current version of icu4c (in this example, 69) compared to mybinary
in the tar file (in this example, 68).
Is there someway to tell the linker at compile time that I want to use libicuuc.dylib
(no version# in the filename)? It would be fine if this behavior then applied to other linked libraries, i.e., I don't need to have it specific for libicuuc.dylib
.
If that's not possible, I could live with modifying the Makefile
to run install_name_tool
but then my dilemma is that there doesn't seem to be an easy way to get libicuuc.68.dylib
. It's not part of the compile console output, and parsing the output of otool -L mybinary
is going to be messy. Is there any easy and elegant way to get libicuuc.68.dylib
for passing to install_name_tool
?
Upvotes: 0
Views: 1209