![](/img/trans.png)
[英]Using mingw-w64 and ./configure --host=i686-w64-mingw32.static, make fails and Makefile CC variable looks wrong
[英]Cross compile with i686-w64-mingw32-g++ and use main() as entry point
I am compiling for Linux in a make target using plain g++
for my linux executable and for windows in a separate make target using i686-w64-mingw32-g++
. 如果我使用 main(),則會構建 g++ 目標,並且 windows 目標會失敗,並顯示:
./build/i686-w64-mingw32-i686-w64-mingw32-crt/./mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain@16'
我嘗試了上面鏈接中的兩種解決方案,但都沒有奏效。
這是我的 windows 構建目標:
RayCaster1.cpp SDLWrapper.cpp -I/usr/local/i686-w64-mingw32/include -L/usr/local/i686-w64-mingw32/lib -lmingw32 -lSDL2 -lSDL2_ttf -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic -o testWindows.exe
添加 -mwindows 或 -Wl,-subsystem,windows 並沒有解決我的問題。 我嘗試一次將其中一個放在末尾,開頭,中間。 我的 windows 構建目標變得非常臃腫,我用另一個標志來煩它了嗎?
這是我的主要 function:
int main(int /*argc*/, char */*argv*/[])
{
SDLWrapper sdlWrapper;
initRasterPixels();
sdlWrapper.setupSDLRenderer(WINDOW_WIDTH, generateRaster);
return 0;
};
使用-mconsole
而不是-mwindows
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.