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++
. If I use main(), the g++ target builds and the windows target fails with:
./build/i686-w64-mingw32-i686-w64-mingw32-crt/./mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain@16'
I tried the two solutions from the link above, but neither worked.
Here is my windows build target:
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
Adding -mwindows or -Wl,-subsystem,windows did not solve the problem for me. I tried putting one of them at a time at the end, beginning, middle. My windows build target has become really bloated, am I borking it with another flag?
Here is my main function:
int main(int /*argc*/, char */*argv*/[])
{
SDLWrapper sdlWrapper;
initRasterPixels();
sdlWrapper.setupSDLRenderer(WINDOW_WIDTH, generateRaster);
return 0;
};
Use -mconsole
instead of -mwindows
.