Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change include from <SDL2/SDL.h> to <SDL.h> #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lrowe
Copy link

@lrowe lrowe commented Mar 2, 2021

To compile on my Mac I needed to change the SDL includes. I've confirmed this still builds successfully on Linux (Debian buster) after making the change but don't know if it would still work on Windows (and have no Windows machine to test on.)

@lrowe
Copy link
Author

lrowe commented Mar 2, 2021

Requirements for building on MacOS 11 Big Sur:

% brew install autoconf automake pkg-config sdl2 wxmac
% autoreconf -i
% ./configure
% make

(In order to run successfully on Mac I also need to change arc_start_main_thread to call arc_main_thread directly rather than in a new thread, as per dpsharp's comment in the forums)

@lrowe
Copy link
Author

lrowe commented Mar 2, 2021

I'm unsure if this is the right approach given emscripten appears to expect #include <SDL2/SDL.h>.

@sjnewbury
Copy link
Contributor

To compile on my Mac I needed to change the SDL includes. I've confirmed this still builds successfully on Linux (Debian buster) after making the change but don't know if it would still work on Windows (and have no Windows machine to test on.)

Shouldn't you just make sure the directory containing the SDL2 include directory is in the header search path? <SDL2/SDL.h> is the usual way to include the SDL.h header. Or does SDL2 get its headers installed differently on the Mac?

@lrowe
Copy link
Author

lrowe commented Apr 22, 2021

Shouldn't you just make sure the directory containing the SDL2 include directory is in the header search path? <SDL2/SDL.h> is the usual way to include the SDL.h header. Or does SDL2 get its headers installed differently on the Mac?

I have sdl2 installed through homebrew, which puts it in /opt/homebrew/include/SDL2:

% sdl2-config --cflags
-I/opt/homebrew/include/SDL2 -D_THREAD_SAFE

While in an Ubuntu docker container I see:

# sdl2-config --cflags
-I/usr/include/SDL2 -D_REENTRANT

Let's look for a more minimal example to see what's going on... Googling throws up examples of both include paths:

Note that neither of these examples actually displays the window on Mac without adding the fix from https://stackoverflow.com/a/41044089

The second builds on Linux with a simple make but not on Mac I need either change to #include <SDL.h> or specify CPATH=/opt/homebrew/include make. So I suppose what's happening is that the Makefile expects the headers to be in the standard header location, i.e. /usr/include as they are on Linux with a distribution installed libsdl2-dev.

I've now found an emscripten example using SDL2 and #include <SDL.h> - https://github.com/robertaboukhalil/wasm-asteroids.

Given the output of sdl2-config, I think #include <SDL.h> is the 'correct' include path to use since it works when sdl2 headers are installed in a non-standard location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants