It seems that in Xcode 4 there is no longer a way to create an application that is not limited to the command line using C or C++. I would like to do so, however Glut seems to be one of the only frameworks available for mac that works with C++ and OpenGL, however gluts features are beginning to stop working on modern Operating Systems. Are there other alternatives that will allow me to use C++ or C for software development on a mac? It does not have to be limited to using xcode or opengl.
-
There are some cross-platform GUI toolkits like Qt and GTK that have Quartz or Cocoa backends, but they invariably result in some degree of non-native look-and-feel. You can write Cocoa apps using mostly C++ and only a tiny bit of Objective-C.user57368– user573682013-01-02 23:16:39 +00:00Commented Jan 2, 2013 at 23:16
-
How? Are there good places to learn how to do this?William Oliver– William Oliver2013-01-02 23:19:47 +00:00Commented Jan 2, 2013 at 23:19
-
SDL works on OSX, doesn't it? Most people use it for games, but there's nothing stopping you from using it for serious work.Ben Voigt– Ben Voigt2013-01-02 23:53:42 +00:00Commented Jan 2, 2013 at 23:53
-
@BenVoigt yes, as does SFMLDavid Brown– David Brown2013-01-02 23:54:49 +00:00Commented Jan 2, 2013 at 23:54
-
I use GLFW + GLEW. Simple and easy.Grimmy– Grimmy2013-01-03 15:12:05 +00:00Commented Jan 3, 2013 at 15:12
3 Answers
Yes, it's possible, but it may not be a very good idea. The real question is what problem are you trying to solve?
If you just don't like Obj-C, it should be straightforward to write a very thin shim that wraps the calls you care about in C++.
If you are trying to prove a point, you can actually make calls directly into the Obj-C runtime in plain C code. See this for example: using objc_msgSend to call a Objective C function with named arguments
If it's something else, please enlighten us so we can better answer your question.
Comments
QT is your best bet. It comes with a serious IDE and the libraries are written in a very good & intuitive C++.
QT can be found here: http://qt-project.org/downloads
1 Comment
If all you want is a window, an OpenGL context, and user interfacing, then go the SDL way. Completely written in C, cross platform, and almost object-oriented (most data types are structs, anyways). It's also very memory economic (its core DLL is less than 500KB in size and a windowless program uses less than 1MB of RAM on Linux), unlike the monster that is Qt.
I'd also recommend LazyFoo's tutorials to get started, since they indeed cover the learning from the perspective of a C++ programmer, not a C one.