tags:

views:

1651

answers:

14

I am looking for alternatives for my current box and Mac OS X seems very appealing.

My main area of interest is C++ programming. Currently I'm using Eclipse + CDT and g++ for creating my software; sometimes it is KDevelop.

I know that primary IDE for Mac is Xcode and primary language is Objective-C. I would like to avoid learning Objective-C if at all possible. I've also heard/read that there are some issues in accessing Mac OS X APIs from C++.

Hence my question: what is the complete solution for developing/debugging/testing C++ applications that access all aspects of hardware (UI, sound, video/accelerated video, etc.) for Mac OS X?

Edit: how does Xcode compare to the Eclipse+CDT combo? If this comparison is at all possible...

A: 

I haven't used it on OSX myself (I can recommend it on Windows), but the Code::Blocks C++ IDE is implemented using, and supports, the cross-platform wxWidgets GUI library. It is supported on OSX - see this page.

anon
+3  A: 

Unless you're looking at using an intermediate layer like QT, I think you're pretty much stuck with Objective C to interface with parts of the API like the GUI as it is their native language.

That said, it has been mentioned that you can easily mix Objective-C code and C++ code so you may still be able to write the majority of your application in C++.

I'm mainly a C++ programmer but I'm always dabbling in other languages and I've had a play with XCode (yes, I've got a Mac). I liked it, it's a bit different but as a way of nailing together an OS X GUI it's superb and the rest is between you and your favourite editor if you don't like XCode that much.

Timo Geusch
My idea is that Linux, which I use now, is very fractured/split when it comes to GUI implementations and APIs. Mac seems a very promising platform.
Marcin Gil
I'm pretty much in the same boat - I'm a longtime Unix/Linux user and developer but I've never really been tempted to write GUI apps for either. And OS X seems to be the best of both worlds with a superb consistent GUI and Unix underneath.
Timo Geusch
A: 

I would advice you to stick with whichever IDE you are most comfortable with. Personally, I hated Xcode the first time I used it and refused to give up Eclipse. After a few days, I warmed up to Xcode and don't mind using it from time to time. However, I still use Eclipse whenever possible.

Just remember that you cannot write Cocoa applications using only C++, you need to dive into Obj-C for that. Carbon applications don't quite look or behave like a Cocoa app. Most people won't really mind but it's something to think about. I jumped into Obj-C from java/C# without any issues. The language takes a little getting used to but it's not very difficult.

Alexander
+5  A: 

Objective-C is not that hard. If you know C++ it will take you a day or three of applied effort to learn the conventions.

The Cocoa APIs and conventions take longer, but those come in time.

Good luck!

Genericrich
+2  A: 

It's no problem using gcc or g++ from OS X. The XCode install gives you these compilers anyway, and if you really wanted, you could load up an x server instance and get KDE working. I like the XCode editor myself though. Eclipse also works with OS X, so you should be able to use your current environment.

I've used an OS X box for cross-compiling C code from PPC arch to ARM arch before, with no problems. It's just another *nix style system, so all the tools you are familiar with will already exist, and if they don't, just use fink or macports to get them yourself.

Also, if you really wanted to use C++ for developing GUI OS X apps, you could always use Carbon instead of Cocoa. It's a perfectly viable choice, only slightly deprecated.

Alex Fort
With introduction of LGPLed QT I am more and more keen on using it.
Marcin Gil
Learning Carbon is a bad idea. Everything for which there is a cocoa equivalent is effectively deprecated, and the carbon gui apis will never be 64-bit clean. It's much better to use Objective-C++ to interface with Cocoa, and use Carbon only where absolutely necessary.
+8  A: 

If you want to use C++ instead of Objective-C, and still want to avoid an intermediate layer of libraries (such as QT), you can use Carbon.

I would use XCode instead of Eclipse simply because Eclipse is way slower when dealing with hardcore C/C++ programming (compiling, debugging, testing).

When I first started to program in Mac OS X, I was in the same page you are now. I thought it was better to stick to the language I knew (C++) and use an older library (Carbon). For some reason I don't remember now, I forced myself into Cocoa (Objective-C). Looking back, I think it was a good thing because:

  1. Objective-C is not fundamentally different to C++
  2. Cocoa is better, faster and simpler than Carbon
  3. iPhone Dev is exclusively Cocoa (Carbon is not supported)
Pablo Santa Cruz
-1 For new application development, going Carbon is really bad advice.
Stephan Eggermont
Read the question. What would you use if you want to code **C++** GUI applications in Mac OS X?
Pablo Santa Cruz
+7  A: 

You should not avoid learning Objective-c and Cocoa. It should in fact be the first thing you do. Unless you have a solid background in Smalltalk, you're unlikely to have been exposed to a large (set of) framework that is as well-designed.

Stephan Eggermont
+1  A: 

Carbon on Mac OS X is effectively deprecated - it does not and will not support 64 bit apps.

If you really really want to use c++, use Qt Creator

Which is now free and the trolltech SDK includes Qt 4.5, which while it is a c++ framework it internally uses Objective-C to interact with MAC OS X, so then you are not limited by Carbon.

The downside is that the trolltech libraries are not standard on the mac, you must provide them with your app.

jdkoftinoff
+3  A: 

I've been playing around using Objective-C++ to write the UI, making it easier to use C++ to write the application back-end. It seems to work pretty well for me. Objective-C & Objective-C++ are pretty easy to pick up and this lets me keep using my hard-won C++ knowledge.

Ferruccio
A: 

If you really want to use C++ on Mac OS X, use something like SDL / wxWidgets / Qt.

There's the option of combining Objective-C with C++, called Objective-C++. You could use it for all your model-stuff and just use Objective-C for the stuff, that isn't possible without the Foundation-framework.

As a last option, Carbon comes to mind. This is a native framework that was used in the pre-OSX times but runs on Mac OS X. The problem is, it's not supported for newer technologies and I think the next release of OS X, Snow Leopard, isn't going to support it at all.

Apple says:

Carbon enables C/C++ developers to take advantage of Mac OS X features, including the Quartz 2D graphics library, an efficient event-handling mechanism, and multiprocessing support. In addition, other industry-standard C/C++ APIs are available to Carbon developers, providing access to such services as the OpenGL drawing system, the Mach microkernel, and BSD operating-system services.

Don't expect Carbon applications to look 100% native and it's much more complicated for programming than Cocoa.

However, I recommend learning Objective-C, it's not hard and there are lots of powerful frameworks like CoreData, CoreGraphics and the like.

Georg
+1  A: 

I agree with Pablo Santa Cruz and would like to add that it's trivial to mix Objective-C with C++ in the same app (and the same source file). This is referred to as Objective-C++ and discussed in this article.

XCode compiles with GCC so you have Objective C, C, and C++ ready at your finger tips.

John Fricker
A: 

For some small hobby projects, and an iPhone app I'm making, I'm using a mix of objective C++ and 'real' C++. XCode supports the mixing of both languages fairly well. I use objective C/objective C++ for the user interface and as a thin layer between the OSX frameworks and my own code. So far, this has turned out to be a great way of working.

Emiel
Oh, and as a small addition to my own answer: It's worth learning ObjC/ObjC++! The language is easy to learn, powerful and allows some very interesting constructs when used with the OSX frameworks. OSX programs can be as polished on the inside as they look on the outside.
Emiel
A: 

The development environment that I am using right now for development in the Mac is QTCreator which is a free IDE for development in QT with gcc as compiler. It gives all the features I need and it is cross platform (one requirement of the application I am developing).

I have to say that I've been fairly impressed. I didn't have high hopes for such a focused (specifically designed for QT) and recent IDE. The environment is easy but powerful (including GUI editing) and has the better code completion I've ever seen. It is a breeze programming in this environment and don't miss a bit Visual Studio.

Really worth a try.

Josep
+1  A: 

C++ works very well with Xcode. If you want cocoa, you can learn a minimal (and I mean really minimal) amount of Obj-C for the gui layer and have the bulk of your code in C++.

Another option is using one of the scripting language frameworks for hooking into the Cocoa API (such as PyObjc) and the bulk of your logic in C++.

The third and final option is using a cross platform gui kit such as Qt4. If there's a desire to make your libraries cross platform, this would be the route to go.

I would recommend against going with Carbon. It's definitely a dying beast. You could also use combinations of the above providing a library with your C++ code then creating gui specific UI's that link them them.

jkyle