I'm trying to write a C program using a library. The library has provided a include/ and lib/ directory with header files and .dylib files, respectively.
My file is in the same directory as include/ and lib/. I'm trying to compile it with the following command:
clang -I"./include/" -L"./lib/" -lcsfml-graphics -lcsfml-window test.c
However, when I go to run my program, I get the following error:
% ./a.out
dyld: Library not loaded: @rpath/libcsfml-graphics.2.4.dylib
Referenced from: ~/src/CSFML-2.4-osx-clang/./a.out
Reason: image not found
zsh: abort ./a.out
What is the correct way to compile using these libraries? I'd prefer to simply use the command line as I'm writing a small program, without having to set up Xcode, etc.
% ls -l lib/
-rwxr-xr-x@ 1 staff 50296 Mar 1 2017 libcsfml-audio.2.4.0.dylib*
lrwxr-xr-x@ 1 staff 26 Mar 1 2017 libcsfml-audio.2.4.dylib@ -> libcsfml-audio.2.4.0.dylib
lrwxr-xr-x@ 1 staff 24 Mar 1 2017 libcsfml-audio.dylib@ -> libcsfml-audio.2.4.dylib
-rwxr-xr-x@ 1 staff 163680 Mar 1 2017 libcsfml-graphics.2.4.0.dylib*
lrwxr-xr-x@ 1 staff 29 Mar 1 2017 libcsfml-graphics.2.4.dylib@ -> libcsfml-graphics.2.4.0.dylib
lrwxr-xr-x@ 1 staff 27 Mar 1 2017 libcsfml-graphics.dylib@ -> libcsfml-graphics.2.4.dylib
-rwxr-xr-x@ 1 staff 67272 Mar 1 2017 libcsfml-network.2.4.0.dylib*
lrwxr-xr-x@ 1 staff 28 Mar 1 2017 libcsfml-network.2.4.dylib@ -> libcsfml-network.2.4.0.dylib
lrwxr-xr-x@ 1 staff 26 Mar 1 2017 libcsfml-network.dylib@ -> libcsfml-network.2.4.dylib