链接器找不到 SDL 库?

问题描述 投票:0回答:1

我正在尝试使用 SDL2 编译示例程序,但它不会为我编译:

g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2main.a when searching for -lSDL2main
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib\libSDL2main.a when searching for -lSDL2main
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2main.a when searching for -lSDL2main
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2main: No such file or directory
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2main.a when searching for -lSDL2main
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2.dll.a when searching for -lSDL2
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2.a when searching for -lSDL2
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib\libSDL2.a when searching for -lSDL2
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2.dll.a when searching for -lSDL2
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2.a when searching for -lSDL2
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2: No such file or directory
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2.dll.a when searching for -lSDL2
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2.a when searching for -lSDL2
collect2.exe: error: ld returned 1 exit status

我真的不知道该怎么办。

c++ visual-studio-code mingw sdl linker-errors
1个回答
0
投票

使用 Microsoft 的 Visual Studio,它可以轻松链接 SDL2,如果您在其他 IDE 上出现错误,例如很难链接动态库。 https://visualstudio.microsoft.com/

© www.soinside.com 2019 - 2024. All rights reserved.