7

I can't seem to compile this program. I have other people in my class that are having no problem compiling this code. I'm using the same command to try to compile the program and installed the frameworks in the same directory as them. /Library/Frameworks. I also installed eclipse and followed the zamma.co.uk tutorial to setup sdl2 and that didn't work either. Here is the command i'm running when compiling

g++ -std=c++11 -o Gravity main.cpp Game.cpp Particle.cpp Point.cpp -I/Library/Frameworks/SDL2.framework/Headers -framework SDL2 -framework Cocoa

Note: I have tried both

#include <SDL.h>

and

#include <SDL2/SDL.h> 

and neither work

rogerdpack
  • 62,887
  • 36
  • 269
  • 388
o.hdz1
  • 83
  • 1
  • 1
  • 4
  • When "neither work" what error output are you getting from `g++`? – Drew MacInnis Dec 06 '15 at 00:39
  • for `#include ` i get `fatal error: 'SDL2/SDL.h' file not found` for `#include ` i get ld: framework not found SDL2 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [all] Error 1 @DrewMacInnis – o.hdz1 Dec 06 '15 at 00:44
  • Does `find /Library/Frameworks/SDL2.framework -name "SDL.h"` find that header file? Is it under an SDL2 directory or somewhere else? – Drew MacInnis Dec 06 '15 at 00:52
  • when i run that command i get this `/Library/Frameworks/SDL2.framework/Versions/A/Headers/SDL.h` @DrewMacInnis – o.hdz1 Dec 06 '15 at 00:53
  • Using `#include ` should work. See [this](http://www.willusher.io/sdl2%20tutorials/2013/08/15/lesson-0-mac-command-line/) tutorial. However I don't believe you need the `-I` option; using `-framework` will do that for you. – trojanfoe Dec 06 '15 at 02:26
  • Answer this question first and the answer will present itself. What is the full path to `SDL.h` from where you installed it? – selbie Dec 06 '15 at 03:48
  • Did you install SDL using `homebrew`? – Mark Setchell Dec 06 '15 at 08:17

1 Answers1

5

The ld linker error you mention in your comments suggests you may need to pass the -F option or -L in case your features/library search path is not finding your SDL2 installation.

Your problem sounds similar to:

Community
  • 1
  • 1
Drew MacInnis
  • 8,267
  • 1
  • 22
  • 18