我一直在尝试用C语言编译SDL2代码,这是一个控制台应用程序 . 我使用Code :: Blocks和GNU GCC Complier . 这是代码:
#include <iostream>
#include <SDL2/SDL.h>
int main( int argc, char *argv[] )
{
if ( SDL_Init( SDL_INIT_EVERYTHING ) < 0)
{
std::cout << "SDL could not initialise! SDL Error: " << SDL_GetError( )<< std::endl;
}
return EXIT_SUCCESS;
}
它给了我这些错误:
undefined reference to `SDL_Init'
undefined reference to `SDL_GetError'
undefined reference to `WinMain@16'
我有"-lmingw32 -lSDL2main -lSDL2" in the other linker options ,并且在 Search directories 中我放了:
- ...... \ SDL2-devel-2.0.5-mingw \ SDL2-2.0.5 \ x86_64-w64-mingw32 \ include in Compiler
在 Linker 中 - ...... \ SDL2-devel-2.0.5-mingw \ SDL2-2.0.5 \ x86_64-w64-mingw32 \ lib
我将所有include,lib和bin文件移动到MinGW的文件夹中 .
知道我做得很糟糕的是什么吗?
谢谢!
1 回答
对于windows,include指令中的sdl头文件必须是:
<SDL2/SDL.h>
用于linux系统 .