🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How can i compile an SDL program on Mac?

Started by
3 comments, last by Splinter of Chaos 12 years, 9 months ago
So, i got this game on Windows and Linux and it requires gcc 4.4 or later for the c++0x features. I got xcode to use a gcc i compiled myself (gcc-fsf-4.6), but xcode immediately responds with an error: "Invalid value 'gcc-fsf-4.6' for GCC_VERSION". Not sure what i can do about that except maybe recompile and manually set its version (somehow).

I would really like not to use xcode at all, but i couldn't find ANY help online about how to do that.
Advertisement

So, i got this game on Windows and Linux and it requires gcc 4.4 or later for the c++0x features. I got xcode to use a gcc i compiled myself (gcc-fsf-4.6), but xcode immediately responds with an error: "Invalid value 'gcc-fsf-4.6' for GCC_VERSION". Not sure what i can do about that except maybe recompile and manually set its version (somehow).

Try this. It did not work for me when I tried it, but you may have better luck. Keep in mind that there will inevitably be issues, especially when trying to compile things like Cocoa apps or targeting iOS. The gcc that comes with XCode is a version heavily modified by Apple, not the standard GNU one. Also note that Apple is in the process of transitioning to clang (due to newer versions of gcc being under GPLv3), but clangs' C++0x support is very mediocre at this point.


I would really like not to use xcode at all, but i couldn't find ANY help online about how to do that.

Use the command line, Netbeans, Eclipse, etc. Tons of alternatives to XCode.
The command line is actually my method, especially considering how much i invested in my makefile. It seems like i need a .h and .m file to get SDLmain to work, but i don't know how to do that.

Thanks for the link, but it's not for Xcode 4 and it seems they've changed a lot of things because all the tutorials i've seen (for more than just SDL) are out of date. Feels like i just chose a bad time to invest in a Mac.
You must add the file SDLMain.m to the list of files you're compiling in your makefile. SDLMain.m contains glue code to use SDL on Mac OS X.

You also need to use the -framework flag and link to the SDL and Cocoa frameworks. SDL on Mac OS X is a framework, not a library. The Mac version of SDL is written in Cocoa, which is why you need to link to the Cocoa framework.
Mark Szymczyk
Author of Mac Game Programming and Xcode Tools Sensei
http://www.meandmark.com
It was the Cocoa framework! And the .m file. Thanks! Got it to compile, but not run:

dyld: lazy symbol binding failed: Symbol not found: __ZNKSt5ctypeIcE13_M_widen_initEv
Referenced from: /Users/hakusa/programming/c++/workspace/orbital-chaos/./run
Expected in: /usr/lib/libstdc++.6.dylib

dyld: Symbol not found: __ZNKSt5ctypeIcE13_M_widen_initEv
Referenced from: /Users/hakusa/programming/c++/workspace/orbital-chaos/./run
Expected in: /usr/lib/libstdc++.6.dylib

[1] 96821 trace trap ./run/code]

Then i modified my code to compile with llvm-g++, but it segfaults when i try and run it. I ran it through gdb and got this:

(gdb) run
Starting program: /Users/hakusa/programming/c++/workspace/orbital-chaos/run
Reading symbols for shared libraries ++++++++++++................................................................................................................................... done
dyld: lazy symbol binding failed: Symbol not found: __ZNKSt5ctypeIcE13_M_widen_initEv
Referenced from: /Users/.../run
Expected in: /usr/lib/libstdc++.6.dylib

dyld: Symbol not found: __ZNKSt5ctypeIcE13_M_widen_initEv
Referenced from: /Users/.../orbital-chaos/run
Expected in: /usr/lib/libstdc++.6.dylib


Program received signal SIGTRAP, Trace/breakpoint trap.
0x00007fff5fc0106d in __dyld_dyld_fatal_error ()[/quote]

I'm really not sure what to make of that. It looks like the problem is it's looking for a standard function that just isn't there... do i not have something installed properly?

This topic is closed to new replies.

Advertisement