我試圖編譯一個簡單的C++程序,該程序在我的Arch Linux(64位)上使用帶有mingw-w64-g ++編譯器的SDL 2。如何使用SDL 2從Linux for Windows進行交叉編譯
爲此,我下載了SDL2-devel的-2.0.4-mingw.tar.gz從here
prog.cpp:
#include <SDL.h>
int main()
{
SDL_Init (SDL_INIT_VIDEO);
SDL_Window *sdlWnd = SDL_CreateWindow ("Test", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, 800, 600, 0);
SDL_Event event;
bool running = true;
while (running) {
while (SDL_PollEvent (&event)) {
if (event.type == SDL_QUIT) {
running = false;
break;
}
}
}
return 0;
}
的Makefile:
GPP = x86_64-w64-mingw32-g++
prog.exe: prog.o
$(GPP) -o prog.exe prog.o -LSDL2-2.0.4/lib/x64 -lSDL2main -lSDL2
prog.o: prog.cpp
$(GPP) -o prog.o -c -ISDL2-2.0.4/include prog.cpp
現在正在給錯誤:
x86_64-w64-mingw32-g++ -o prog.exe prog.o -LSDL2-2.0.4/lib/x64 -lSDL2main -lSDL2
Warning: corrupt .drectve at end of def file
SDL2-2.0.4/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[main]+0x1c): undefined reference to `SDL_main'
爲什麼對'SDL_main'的未定義引用?雖然我指定了-lSDL2main?
我做錯了什麼? :(
的可能的複製[找不到sdl2main] (http://stackoverflow.com/questions/22739563/cannot-find-sdl2main) – Pierre