Reputation:
I have a perfectly working C program using SDL that I can compile with
gcc main.c -o program `sdl-config --libs` -lSDL
The program is simple, it comes up with a black window and waits for the user to close it. No problems or errors. I have MinGW installed and I'm trying to use x86_64-w64-mingw32-gcc
to cross-compile it; I would like to know how to cross-compile this for Windows on Linux and include the necessary libraries.
Upvotes: 4
Views: 2962
Reputation: 5819
You can invoke MinGW’s GCC like your Linux version, but you might need to replacesdl-config
with some manual configuration like so:
x86_64-w64-mingw32-gcc -Ipath/to/SDL/headers \
-Lpath/to/SDL/libs \
-o program main.o \
-lSDL -lSDLmain
You will need to download SDL.lib and SDLmain.lib. I believe they are part of the development zip. (Edit: as noted in the comments, you might not need to use the libs but can just use the DLLs.)
This might pop up a console window when running. Pass in the -mwindows
flag to target the Windows subsystem instead.
Upvotes: 3