Skip to content

Conversation

@kenohassler
Copy link

After using make install, ecdsautil would crash on my Mac with the following error message:

dyld[98560]: Library not loaded: @rpath/libecdsautil.0.dylib
Referenced from: <0202E251-97CE-3FCF-A529-5B723AC042A0> /usr/local/bin/ecdsautil
Reason: no LC_RPATH's found

Basically, dyld does not know where to load the library from. To fix this, define LC_RPATH by setting INSTALL_RPATH via cmake. This seems to be an Apple thing, but I used CMAKE_INSTALL_PREFIX to be platform-agnostic just to be sure.

Additionally, I addressed an unrelated cmake warning by changing the capitalization of "libuecc". I tested building on macOS 26 and Debian 13, both worked flawlessly.

CMake (v4.2.1) reported the following warning:
  The package name passed to find_package_handle_standard_args() (LIBUECC)
  does not match the name of the calling package (libuecc).  This can lead to
  problems in calling code that expects find_package() result variables
  (e.g., `_FOUND`) to follow a certain pattern.

This warning can be fixed by changing the spelling in Findlibuecc.cmake
from "LIBUECC" to "libuecc".
After installing with `make install`, ecdsautil would crash on macOS:
  dyld[98560]: Library not loaded: @rpath/libecdsautil.0.dylib
    Referenced from: <0202E251-97CE-3FCF-A529-5B723AC042A0> /usr/local/bin/ecdsautil
    Reason: no LC_RPATH's found

To fix this, set INSTALL_RPATH in src/cli/CMakeLists.txt.
This should be platform-agnostic, as it uses CMAKE_INSTALL_PREFIX.
@neocturne
Copy link
Member

Hmm, setting the rpath should only be necessary when the dylib is installed to a non-standard library location - /usr/local/lib should work by default though according to https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/UsingDynamicLibraries.html. Maybe some cache needs to be updated?

I would it consider bad style to set an rpath when it is not actually necessary - most software does not set one.

@kenohassler
Copy link
Author

Hi, thanks for taking a closer look. As it definitely didn't work on my system, I tried to find more up-to-date documentation.
man dyld gives me the following:

DYLD_FALLBACK_LIBRARY_PATH
This is a colon separated list of directories that contain libraries. If a dylib is not found at its install path, dyld uses this as a list of directories to search for the dylib.

For new binaries (Fall 2023 or later) there is no default. For older binaries, there is a default fallback search path of: /usr/local/lib:/usr/lib.

I would guess this means the default interpretation of @rpath changed as well?

@neocturne
Copy link
Member

See also https://cmake.org/cmake/help/latest/prop_tgt/MACOSX_RPATH.html and https://cmake.org/cmake/help/latest/policy/CMP0042.html, but my knowledge of macos is not sufficient to interpret what "using rpath" means here.

@kenohassler
Copy link
Author

Nope, this didn't help either. I have tried setting MACOSX_RPATH FALSE in the target properties in src/lib/CMakeLists.txt. After make install, the following error is thrown:

dyld[10011]: Library not loaded: libecdsautil.0.dylib
  Referenced from: <0499A25C-9F48-355D-B026-7D1474508474> /usr/local/bin/ecdsautil
  Reason: tried: 'libecdsautil.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibecdsautil.0.dylib' (no such file), 'libecdsautil.0.dylib' (no such file), '/Users/<private>/ecdsautils/build/libecdsautil.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/<private>/ecdsautils/build/libecdsautil.0.dylib' (no such file), '/Users/<private>/ecdsautils/build/libecdsautil.0.dylib' (no such file)

The manual page on MACOSX_RPATH also states that

Runtime paths will also be embedded in binaries using this target and can be controlled by the INSTALL_RPATH target property on the target linking to this target.

So I think setting INSTALL_RPATH might actually be the way to go. Happy to test something else though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants