1

I'm working on a project in c++ that uses autotools for easy cross-compile. I've sudo make install'd MXE on my system. When just using ./configure, and thus using g++, things run smoothly. However, using ./configure --host=i686-w64-mingw32, I run into this error:

In file included from Game.cpp:1:0:
Game.hpp:4:22: fatal error: SDL2/SDL.h: No such file or directory
#include <SDL2/SDL.h>

After fishing around Google all day, I can't seem to find an indicator as to why. I know that when compiling on Win(currently on Ubuntu 15.04), the headers are named differently for SDL, but I'm still using a Unix compiler, according to my understanding. Do I need to have separate source for Windows, with a different include? I monitored the mxe install for errors and received none, so I can't conceive of that being the issue.

If needed, I can provide a more complete picture of the environment, but I believe this to perhaps be an OS specific error/caveat.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Bloodyaugust
  • 2,463
  • 8
  • 30
  • 46
  • Do you actually have SDL.h file or is it named differently? What happens when you add `-I/path/to/SDL2/` in your compiler options? What does `pkg-config --cflags SDL2` say? – Dmitry Grigoryev Jun 29 '15 at 13:21
  • I'll try the -I flag approach and report back. `sdl2-config --cflags` outputs : `-I/usr/include/SDL2 -D_REENTRANT`. `SDL.h` exists in `/usr/include/SDL2/`. – Bloodyaugust Jun 29 '15 at 15:41
  • Make sure you don't include `SDL2` twice. If you use `-I/usr/include/SDL2` and `#include `, the compiler will be looking for `/usr/include/SDL2/SDL2/SDL.h` – Dmitry Grigoryev Jun 30 '15 at 07:00

1 Answers1

1

SDL2 headers should be included as follows:

#include <SDL.h>

Not:

#include <SDL2/SDL.h>

Why?

Because when you run sdl2-config --cflags its outputs a path like this include/SDL2 and if you do a ls on it you will get SDL.h not SDL2/SDL.h.

  • But as I described in my post, `make`ing when configured for a *nix system works fine. You can see the output of the config cflag in the comment on the main post. – Bloodyaugust Jun 29 '15 at 15:46
  • @Bloodyaugust it will be a configuration error, check your paths. If you use `#include ` on unix-like systems it will work because the SDL2 is on the standard include path but it does not happens on windows, so you will have to use `#include `, any other error is from the configuration you have. – Jean Pierre Dudey Jun 29 '15 at 16:04