我无法在代码块中编译我的 SDL 项目

I can't compile my SDL project in CodeBlocks

本文关键字:编译 我的 SDL 项目 代码      更新时间:2023-10-16

构建日志

-------------- Build: Debug in SDLTEST (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -LC:MingwLibsSDL2-2.0.3lib -o binDebugSDLTEST.exe  objDebugmain.o  -lmingw32 -lSDL2main -lSDL2  
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../mingw32/bin/ld.exe: cannot find -lSDL2main
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../mingw32/bin/ld.exe: cannot find -lSDL2
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))

我的代码

当我使用标签时,它使include变为粗体。

(#)include <stdio.h>
(#)include <SDL.h>
using namespace std;
int main( int argc, char* args[] )
{
SDL_Init(SDL_INIT_EVERYTHING);
    SDL_Quit();
    return 0;
}

我的链接器

-lmingw32 -lSDL2main -lSDL2

看起来您的库搜索路径错误。SDL2的标准分发包在lib文件夹中包含两个文件夹,但您可以直接将路径设置为

-LC:\MingwLibs\SDL2-2.0.3\lib

尝试使用C:\MingwLibs\SDL2-2.0.3\lib\x86C:\MingwLibs\SDL2-2.0.3\lib\x64作为库路径