Public Group

# Compiling SDL with MinGW on Window 8.1?

This topic is 1060 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am new to SDL and to cross-platform in general.

I want to recompile SDL just to make sure I can eventually change it if needed, and then a few demos on my Windows 8.1 development machine.

I would also like to use open source compilers if possible so I installed codeblocks IDE + MinGW and tried to compile the SDL 2.0.3 source code.

It first failed saying it needed ddraw.h so I installed 'Direct X SDK' (I only plan on using OpenGL but I am told that DirectX is required for joystick input) but then I found on a forum that it was replaced by 'Windows 8.x SDK' , so I installed 'Windows 8.1 SDK' and added the include directories but now I get '...\Include\um\winnt.h|938|error: #error Must define a target architecture.' so I am starting to wonder if using MinGW is a valid way to compile SDL on Windows.

I looked at some of the wiki on codeblocks about recompiling SDL but they are 10+ years old:

http://wiki.codeblocks.org/index.php?title=Using_SDL_with_Code::Blocks

I also looked at some info on the SDL site but they mention an August 2007 DirectX SDK so it does not look too recent either:

##### Share on other sites
Don't use vanilla MinGW. Life is easier with a distribution like TDM-GCC, which is based on MinGW-w64. I comes with all of the DirectX headers and libraries you'll need. I also recommend installing MSYS2 and working through that rather than the Windows cmd shell, if you aren't already.

Furthermore, it's generally a bad idea to mix things compiled via the Microsoft toolchain with MinGW, such as the binaries found in the Windows SDK. MinGW can link dynamically with DLLs if you pass them along, but attempting to link with static or import libraries is asking for trouble. Any third-party libraries you use should generally be compiled with MinGW as well. Edited by Aldacron

##### Share on other sites

I installed TDM-GCC as you suggested.  The compilation went a lot farther but now I get:
...\SDL2-2.0.3\src\audio\xaudio2\SDL_xaudio2.c|95|fatal error: xaudio2.h: No such file or directory

So I tried adding the 'Windows 8.1 SDK' which does contain xaudio2.h but then it seems to get stuck with the original problem:
...\Windows SDK 8.1\Include\um\winnt.h|147|error: #error "No Target Architecture"

Not sure if Msys2 is required to rebuild SDL or if MinGW is enough.

I agree it looks like trouble to mix Microsoft libs with MinGW but SDL is including directX headers and Microsoft headers can include whatever they like (e.g. windows.h, winnt.h).

Edited by virtualpaul

##### Share on other sites
How are you building? CMake should be looking for xaudio2.h and, failing to find it, configure the makefile so that it isn't enabled. I just tried it out using the Windows cmd prompt (I normally build through MSYS) to be sure it works for me:

cd sdl-source-dir
mkdir build
cd build
CMake -G"MinGW Makefiles" ..

-->CMake spits out a lot of stuff here, including:
-- Looking for d3d9.h
-- Looking for d3d11_1.h
-- Looking for ddraw.h
-- Looking for dsound.h
-- Looking for dinput.h
-- Looking for xaudio2.h

---> Then, when it finishes:
mingw32-make

I get both static and dynamic versions of SDL successfully compiled as a result. I don't know why CMake isn't finding the DX headers, though, as I'm looking at most of them in Windows Explorer, but that's beside the point. Edited by Aldacron

##### Share on other sites

You may need to write and install a FindXXX.cmake script or use cmake-gui and manually change some variables, because cmake is not very intelligent and there are no standardised paths on Windows for finding libraries.

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 28
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631772
• Total Posts
3002260
×