AndreaOrru / LaiNES

Cycle-accurate NES emulator in ~1000 lines of code
BSD 2-Clause "Simplified" License
1.49k stars 122 forks source link

Building on OSX with brew requires some extra flags #14

Closed jasonwatkinspdx closed 4 years ago

jasonwatkinspdx commented 7 years ago

Building on OSX for me needed some extra flags in the SConstruct.

Error:

>  scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
clang++ -o src/Sound_Queue.o -c -O3 -march=native -std=c++11 -Wno-unused-value -Isrc src/Sound_Queue.cpp
In file included from src/Sound_Queue.cpp:4:
src/Sound_Queue.h:9:10: fatal error: 'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>
         ^
1 error generated.
scons: *** [src/Sound_Queue.o] Error 1
scons: building terminated because of errors.

I get a successful build with:

diff --git a/SConstruct b/SConstruct
index d9b6582..e95887f 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1,6 +1,6 @@
 from os import environ

-flags = ['-O3', '-march=native', '-std=c++11']
+flags = ['-O3', '-march=native', '-std=c++11', '-I/usr/local/include', '-L/usr/local/lib']

 env = Environment(ENV       = environ,
                   CXX       = 'clang++',

But it also has a bunch of build spam like:

clang: warning: argument unused during compilation: '-L/usr/local/lib'

for every unit that doesn't need SDL. I'm an ignoramus when it comes to scons so posting an issue vs a pull request in the hope someone else knows how to resolve that trivially.

jaymzcd commented 7 years ago

I just cloned and built on OS X (sierra) without any issue. Not sure if it makes a difference or not but I had just done the brew install scons sdl2 sdl2_image sdl2_ttf step and then immediately scons. The versions it installed are on this gist. The scons build output there is totally clean and I didn't have to touch the Sconsfile.

MainReturnZero commented 7 years ago

I have the same issue with Jason. After I follow Jason's method, I also encountered that the library is not included.

xyproto commented 7 years ago

No issues with macOS Sierra and homebrew here.

AndreaOrru commented 7 years ago

I can't reproduce this. First thing I can think of: do you have the Xcode CLI tools installed?

michaelclarkjr commented 7 years ago

I got the same problem and fixed it with the above flags. For those with no issues, it could be an OS version thing (I'm running El Cap, not Sierra).

MainReturnZero commented 7 years ago

Xcode CLI is installed in my system.

AndreaOrru commented 7 years ago

I'll leave this open for now. I'll try to test in on other Mac machines and see if I can reproduce it.

Xeon3D commented 7 years ago

I also don't have a problem building latest version on Sierra 10.12.5.

AndreaOrru commented 4 years ago

I'm gonna assume this works now. Let me know if it doesn't.