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

[MacOS 15.1] fatal error: 'SDL2/SDL.h' file not found #1

Closed
johnjohnsp1 opened this issue Nov 19, 2024 · 8 comments
Closed

[MacOS 15.1] fatal error: 'SDL2/SDL.h' file not found #1

johnjohnsp1 opened this issue Nov 19, 2024 · 8 comments

Comments

@johnjohnsp1
Copy link

Hi,
thanks for sharing the project, actually im on a MacOS Sequoia 15.1, followed your instructions but stuck at:

make
cd src && /Library/Developer/CommandLineTools/usr/bin/make all
/Library/Developer/CommandLineTools/usr/bin/make -C ./audio all
gcc -g -O2 -Wall -O0 -I.. -c apu.c -o apu.o
In file included from apu.c:1:
In file included from ./apu.h:4:
./../system.h:10:10: fatal error: 'SDL2/SDL.h' file not found
10 | #include <SDL2/SDL.h>
| ^~~~~~~~~~~~
1 error generated.
make[2]: *** [apu.o] Error 1
make[1]: *** [audio/apu.o] Error 2
make: *** [all] Error 2

i have installed SDL2 at this path:
/Library/Frameworks/SDL2.framework
and added in the $path over .zshrc

export PATH=/opt/homebrew/opt/curl/bin:/opt/homebrew/opt/openssl@3/bin:/Library/Frameworks/SDL2.framework/Headers:$PATH

did also .zshrc and restarted the terminal but no way the ./configure keep saying no SDL found

ecking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for stdlib.h... (cached) yes
checking for stdint.h... (cached) yes
checking for time.h... yes
checking for SDL2/SDL.h... no
checking for SDL2/SDL_ttf.h... no
checking for stdarg.h... yes
checking for stdio.h... (cached) yes
checking for gcc... (cached) gcc
checking whether the compiler supports GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to enable C11 features... (cached) none needed
checking for a BSD-compatible install... /usr/bin/install -c
configure: creating ./config.status

also did installed with brew but nothing

... any ideas ?

regards

@zeim839
Copy link
Owner

zeim839 commented Nov 19, 2024

Seems like the compiler can't find the SDL header files. What you've specified in your PATH variable are (presumably) the locations of the library itself, not its headers.

I also forgot to mention that you need to install SDL2_ttf.

Basically, you need to find the location of your SDL2 header files and library objects and pass them to configure script. The instructions below should outline the process.

Install Dependencies

Install SDL2 and SDL2_ttf from homebrew:

brew install SDL2
brew install SDL2_ttf

Locate header files

Locate your SDL2 header file location. By default, it should be in /usr/local/include:

ls /usr/local/include/sdl2/

You can also try searching for it in homebrew's Cellar directory (replace the version to whatever you've installed):

ls /usr/local/Cellar/sdl2/2.30.6/include
ls /usr/local/Cellar/sdl2_ttf/2.22.0/include/

Create a symbolic link

Create a symbolic link to SDL_ttf within the SDL directory. The header file for SDL2_ttf assumes that the SDL_ttf.h is in the same directory as the rest of the SDL library (which is not actually the case).

ln -s /usr/local/Cellar/sdl2_ttf/2.22.0/include/SDL2/SDL_ttf.h /usr/local/include/SDL2/SDL_ttf.h

Again, replace the paths with whatever values are appropriate for your installation.

Locate library files

The library files should (by default) be located at /usr/local/lib/libSDL2.a and /usr/local/libSDL2_ttf.a. If that's not the case, you can try searching for them in homebrew's cellar:

ls /usr/local/Cellar/sdl2/2.30.6/lib
ls /usr/local/Cellar/sdl2_ttf/2.22.0/lib

Specify compiler/linker flags

Assuming your SDL_ttf.h is in the same directory as SDL.h (which should be the case following the symbolic link step), you may now pass the header files into the configure script's CFLAGS variable:

CFLAGS="-I/usr/local/Cellar/sdl2/2.30.6/include"

And the library paths into LDFLAGS:

LDFLAGS="-L/usr/local/Cellar/sdl2/2.30.6/lib -L/usr/local/Cellar/sdl2_ttf/2.22.0/lib"

All together (call the configure script):

./configure CFLAGS="-I/usr/local/Cellar/sdl2/2.30.6/include" LDFLAGS="-L/usr/local/Cellar/sdl2/2.30.6/lib -L/usr/local/Cellar/sdl2_ttf/2.22.0/lib"

If the script passes, you should be able to build with the make command. Let me know if this resolves your issue.

@zeim839 zeim839 changed the title fatal error: 'SDL2/SDL.h' file not found [MacOS 15.1] fatal error: 'SDL2/SDL.h' file not found Nov 19, 2024
@johnjohnsp1
Copy link
Author

thanks for the reply
fixed the step for configure, now the command it works
checking for SDL2/SDL.h... yes
checking for SDL2/SDL_ttf.h... yes
but make still complain about sdl2:

make
cd src && /Library/Developer/CommandLineTools/usr/bin/make all
/Library/Developer/CommandLineTools/usr/bin/make -C ./audio all
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I.. -c apu.c -o apu.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I.. -c audio.c -o audio.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I.. -c biquad.c -o biquad.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I.. -c dmc.c -o dmc.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I.. -c noise.c -o noise.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I.. -c pulse.c -o pulse.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I.. -c triangle.c -o triangle.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I. -c bus.c -o bus.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I. -c cpu6502.c -o cpu6502.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I. -c emulator.c -o emulator.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I. -c font.c -o font.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I. -c gfx.c -o gfx.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I. -c joypad.c -o joypad.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I. -c log.c -o log.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I. -c main.c -o main.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I. -c mapper.c -o mapper.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I. -c ppu.c -o ppu.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I. -c timerx.c -o timerx.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -Wall -O0 -I. -o nes-tools audio/apu.o audio/audio.o audio/biquad.o audio/dmc.o audio/noise.o audio/pulse.o audio/triangle.o bus.o cpu6502.o emulator.o font.o gfx.o joypad.o log.o main.o mapper.o ppu.o timerx.o -lm -lSDL2 -lSDL2_ttf
ld: library 'SDL2' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [nes-tools] Error 1
make: *** [all] Error 2

@zeim839
Copy link
Owner

zeim839 commented Nov 20, 2024

Ok, I see. I'll modify the build scripts to make this easier.
Apologies.

@zeim839
Copy link
Owner

zeim839 commented Nov 20, 2024

Let me know if this works:

Make sure you're synced to the latest commit:

git pull origin main

Pass the SDL2 and SDL2_ttf prefix directories as configuration variables:

./configure --with-sdl-prefix=/usr/local/cellar/sdl2/2.30.6 --with-sdl-ttf-prefix=/usr/local/Cellar/sdl2_ttf/2.22.0

Call make:

make clean
make

Make sure you're specifying prefix directories, i.e. the directories should have include and lib as subdirectories within them.

@johnjohnsp1
Copy link
Author

did as you suggested but now on I type:
./configure --with-sdl-prefix=/opt/homebrew/Cellar/sdl2/2.30.9/include/SDL2/ --with-sdl-ttf-prefix=/opt/homebrew/Cellar/sdl2_ttf/2.22.0/include/SDL2

getting this

checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking for a BSD-compatible install... /usr/bin/install -c
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for SDL2/SDL_ttf.h... yes
configure: SDL2_ttf headers found
checking for TTF_Init in -lSDL2_ttf... no
configure: error: SDL2_ttf library not found in /lib

is that a problem since I have SDL2 inside /opt/homebrew/Cellar instead /usr/local/Cellar ?

@zeim839
Copy link
Owner

zeim839 commented Nov 20, 2024

Use:

--with-sdl-prefix=/opt/homebrew/Cellar/sdl2/2.30.9
--with-sdl-ttf-prefix=/opt/homebrew/Cellar/sdl2_ttf/2.22.0

@johnjohnsp1
Copy link
Author

awesome, worked

./configure --with-sdl-prefix=/opt/homebrew/Cellar/sdl2/2.30.9 --with-sdl-ttf-prefix=/opt/homebrew/Cellar/sdl2_ttf/2.22.0
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking for a BSD-compatible install... /usr/bin/install -c
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for SDL2/SDL_ttf.h... yes
configure: SDL2_ttf headers found
checking for TTF_Init in -lSDL2_ttf... yes
configure: SDL2_ttf library found
checking for SDL2/SDL.h... yes
configure: SDL2 headers found
checking for SDL_Init in -lSDL2... yes
configure: SDL2 library found
checking for stdlib.h... (cached) yes
checking for stdint.h... (cached) yes
checking for time.h... yes
checking for SDL2/SDL.h... (cached) yes
checking for SDL2/SDL_ttf.h... (cached) yes
checking for stdarg.h... yes
checking for stdio.h... (cached) yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating src/audio/Makefile
config.status: creating src/config.h
config.status: src/config.h is unchanged
make

cd src && /Library/Developer/CommandLineTools/usr/bin/make all
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -I/opt/homebrew/Cellar/sdl2/2.30.9/include -I/opt/homebrew/Cellar/sdl2_ttf/2.22.0/include/SDL2 -Wall -O0 -I. -c main.c -o main.o
gcc -I/opt/homebrew/Cellar/sdl2/2.30.9/include -I/opt/homebrew/Cellar/sdl2/2.30.9/include -I/opt/homebrew/Cellar/sdl2_ttf/2.22.0/include/SDL2 -Wall -O0 -I. -L/opt/homebrew/opt/curl/lib -L/opt/homebrew/Cellar/sdl2/2.30.9/lib -L/opt/homebrew/Cellar/sdl2_ttf/2.22.0/lib -lm -lSDL2 -lSDL2_ttf -o nes-tools audio/apu.o audio/audio.o audio/biquad.o audio/dmc.o audio/noise.o audio/pulse.o audio/triangle.o bus.o cpu6502.o emulator.o font.o gfx.o joypad.o log.o main.o mapper.o ppu.o timerx.o

@zeim839
Copy link
Owner

zeim839 commented Nov 20, 2024

Awesome, thanks for opening this issue.

The emulator currently only supports mapper #0 games.
You can check out a list of supported games here:

https://nesdir.github.io/mapper0.html

@zeim839 zeim839 closed this as completed Nov 20, 2024
@zeim839 zeim839 pinned this issue Nov 20, 2024
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

No branches or pull requests

2 participants