How to link libraries on macOS?
My folder structure looks like this:
1 2 3 4 5 6 7 8 9 10
|
.
├── src
│ └── main.cpp
└── vendor
└── SFML
├── Frameworks
├── extlibs
├── include
├── lib
└── templates
|
My build scripts looks like this:
1 2 3 4 5
|
run:
g++ -c -std=c++14 src/main.cpp -Ivendor/SFML/include
g++ main.o -o game -Lvendor/SFML/lib -lsfml-graphics -lsfml-window -lsfml-system
rm main.o
export LD_LIBRARY_PATH=vendor/SFML/lib && ./game
|
It compiled fine, but I got this error when I tried to run:
|
dyld: Library not loaded: @rpath/../Frameworks/freetype.framework/Versions/A/freetype
|
(the freetype.framework is under vendor/SFML/extlibs, I'm not sure what @rpath is)
How to run the program with all the libraries correctly linked?
Also I was originally using SFML installed with homebrew and it works fine, I just couldn't get it working this way
Last edited on
I'e solved the issue by adding -rpath argument when compiling:
1 2 3
|
run:
g++ -F vendor/SFML/Frameworks -I vendor/SFML/include -rpath vendor/SFML/Frameworks -framework sfml-window -framework sfml-graphics -framework sfml-system src/main.cpp -o game
./game
|
Last edited on
Topic archived. No new replies allowed.