libui.cr
libui.cr copied to clipboard
dyld: Library not loaded: @rpath/libui.A.dylib
Hello,
I see the note in the readme which advises to add -L$(pwd)
as a linker flag to avoid this error, but I am still getting it. (I'm on macos)
My project structure is essentially:
- TESTAPP/
-
- lib/
-
-
- libui/
- libui/
-
-
- src/
- src/
When I try to do a crystal build
, it reports no errors, and generates an executable ./TESTAPP
, but hen I try to run it I get the "library not loaded" error
Here's the first of the output of otool -L ./TESTAPP
:
./TESTAPP:
@rpath/libui.A.dylib (compatibility version 0.0.0, current version 0.0.0)
...<< other libraries that are found >>
This problem may have something to do with my installation set up, because I have installed libui through homebrew, and my path is non standard. However, I have LD_LIBRARY_PATH and DYLD_LIBRARY_PATH set up to handle this, and it works with other libraries, but I could have missed something common.
I can get the program to run fine by running the command:
install_name_tool -change "@rpath/libui.A.dylib" "/Users/cadebrown/programs/homebrew/lib/libui.dylib" ./TESTAPP
Which manually changes it to the explicit value of the dynamic library. But, I have to do this on each crystal build
and I'd rather not have a Makefile to automate this and just use crystal's system directly.
Any help would be much appreciated!
I had the same issue, and I fixed it by installing libui.
# Clone the https://github.com/andlabs/libui repo and cd into it.
$ mkdir build
$ cd build
$ cmake .. -DBUILD_SHARED_LIBS=OFF
$ make
$ sudo cp -a ./out/. /usr/local/lib/
Fixed the issue, check out my makefile I made to solve this : https://github.com/Iainmon/macOS-crystal-packaging/blob/master/Makefile