ngscopeclient / scopehal-apps

ngscopeclient and other client applications for libscopehal.
https://www.ngscopeclient.org/
BSD 3-Clause "New" or "Revised" License
535 stars 83 forks source link

macOS: ngscopeclient binary is missing RPATH load command #622

Open rgov opened 8 months ago

rgov commented 8 months ago

I built ngscopeclient on macOS 14.0. The binary links in several libraries using @rpath:

% otool -L $(which ngscopeclient) | grep @rpath  
    @rpath/libscopeprotocols.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libscopeexports.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libscopehal.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libvulkan.1.dylib (compatibility version 1.0.0, current version 1.3.231)

However the binary does not contain any LC_RPATH load commands, so @rpath is undefined.

% ngscopeclient                              
dyld[45566]: Library not loaded: @rpath/libscopeprotocols.dylib
  Referenced from: <87EE124C-9597-35DF-9F0A-5A19B4B39F9F> /opt/homebrew/Cellar/ngscopeclient/HEAD-6056adc/bin/ngscopeclient
  Reason: no LC_RPATH's found

Note: I built using the Homebrew formula in this issue.

azonenberg commented 8 months ago
rgov commented 8 months ago

I added the CMake argument -DCMAKE_INSTALL_RPATH="@loader_path/../lib;/opt/VulkanSDK/1.3.231.1/macOS/lib" to work around the issue.

Load command 50
    cmd LC_RPATH
     cmdsize 48
     path /opt/VulkanSDK/1.3.231.1/macOS/lib (offset 12)
Load command 54
     cmd LC_RPATH
     cmdsize 32
     path @loader_path/../lib (offset 12)
azonenberg commented 8 months ago

Yeah I don't think we currently have install support on macos (i.e. it's assumed you are running from the build directory).

Not surprised there's rough edges if you try to do a systemwide install, but the feedback is welcome as proper installability/packaging is one of the things we're trying to fix before the v0.1 release.

d235j commented 5 months ago

You probably need -DCMAKE_INSTALL_RPATH=#{rpath} in your formula, as many other formulas also have this.