Jump to content
  • Advertisement
Sign in to follow this  
Splinter of Chaos

How can i compile an SDL program on Mac?

This topic is 2444 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!