我正在使用 Code::Blocks,这是我的代码:
#include "SDL2/SDL.h"
int main(int argc, char* args[]) {
SDL_Init( SDL_INIT_EVERYTHING );
SDL_Quit();
return 0;
}
我正在构建:
mingw32-g++.exe -o C:\..\main.exe C:\..\main.o -lmingw32 -lSDL2main -lSDL2
并得到:
undefined reference to "SDL_Init"
undefined reference to "SDL_Quit"
I'm pretty sure the linker finds the libs cause if I change them to something random it complains "can't find whatever".
有点晚了,但我刚刚在 Linux 上偶然发现了类似的问题。
这会导致链接器错误:
g++ $(pkg-config --cflags --libs sdl2) sdl2test.cpp
sdl2test.cpp:(.text+0x11): undefined reference to `SDL_Init'
sdl2test.cpp:(.text+0x20): undefined reference to `SDL_GetError'
sdl2test.cpp:(.text+0x34): undefined reference to `SDL_Quit'
这有效:
g++ sdl2test.cpp $(pkg-config --cflags --libs sdl2)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)