'G++, SDL Compilation problem (compiler does not see the library)
after updating g++ to 11.2.0 (before that I had a very old version), I can't compile my project with the same command. For some reason, the compiler cannot find the sdl library, although everything worked fine before.
C:\Users\*****\Desktop\****>g++ -I/src/include -L/src/lib -o main main.cpp -lmingw32 -lSDL2_ttf -lSDL2main -lSDL2 -lSDL2_image
main.cpp:5:10: fatal error: SDL2/SDL.h: No such file or directory
5 | #include <SDL2/SDL.h>
| ^~~~~~~~~~~~
compilation terminated.
I also tried to use the local path, but still unsuccessful. Then it gives me this error.
C:\Users\*****\Desktop\*****>g++ -Isrc/include -Lsrc/lib -o main main.cpp -lmingw32 -lSDL2_ttf -lSDL2main -lSDL2 -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_ttf.dll.a when searching for -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_ttf.a when searching for -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib\libSDL2_ttf.a when searching for -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_ttf.dll.a when searching for -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_ttf.a when searching for -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_ttf.dll.a when searching for -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_ttf.a when searching for -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2main.a when searching for -lSDL2main
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib\libSDL2main.a when searching for -lSDL2main
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2.dll.a when searching for -lSDL2
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2.a when searching for -lSDL2
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib\libSDL2.a when searching for -lSDL2
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_image.dll.a when searching for -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_image.a when searching for -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib\libSDL2_image.a when searching for -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_image.dll.a when searching for -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_image.a when searching for -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_image.dll.a when searching for -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_image.a when searching for -lSDL2_image
collect2.exe: error: ld returned 1 exit status
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
