0

I am trying to setup a C++ project using LDS2. I am having some problems with the compiler. I am working on a M1 Mac and I have installed LDS2 using brew (install location /opt/homebrew/Cellar/sdl2). The project folder structure is as follows:

.
├── Makefile
├── build
├── include
│   └── SDL2 -> /opt/homebrew/Cellar/sdl2/2.0.22/include/SDL2
├── lib
│   └── SDL2 -> /opt/homebrew/Cellar/sdl2/2.0.22/lib/
└── src
    └── main.cpp

I then run the command g++ -std=c++11 -Wall -O0 -g -lSDL2 -Iinclude src/main.cpp -o build/debug/tst to compile the program. However, I get the following error:

ld: library not found for -lSDL2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1

Thank you in advance for your help!

ggiuli
  • 55
  • 9
  • When you type `g++ --version`, what version do you get? – Eljay Jul 27 '22 at 23:29
  • `Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1 Apple clang version 13.0.0 (clang-1300.0.29.30) Target: arm64-apple-darwin21.2.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin` – ggiuli Jul 28 '22 at 18:14
  • This tells me you are not compiling with GNU's `g++`, you are instead compiling with Apple's `clang++`. Is that okay for your project? Also, you are not providing `-L/project/path/lib/SDL2` which probably means `-lSDL2` cannot be found on the default library search path. – Eljay Jul 28 '22 at 19:25

0 Answers0