Michael
Michael

Reputation: 3

How do I get gcc 4.5 (compiled from source) to work with Objective C|C++ programs on Mac OS X?

Anyone,

I have been unable to compile some packages, like WxWidgets, on Mac OS 10.6.4 using gcc 4.5 (compiled from source, not from MacPorts, Fink, etc. with all default languages and Obj-C++). Typically, when trying to compile against the Foundation framework, I get errors such as the following:

/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:123:35:error: expected ‘;’ before ‘__attribute__’
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:138:1:error: stray ‘@’ in program
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:139:1:error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘-’ token In file included from main2.m:2:0:
/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:139:63:error: expected ‘;’ before ‘__attribute__’

I'm somewhat somewhat new developing on the Mac (more experience with Linux and Windows). Right now, I don't need to use Objective-C or Objective-C++. It's just getting in the way of being able to compile other packages (though I may want to start using it down the road). If anyone has any thoughts I would appreciate it. Thank you.

Upvotes: 0

Views: 662

Answers (2)

Phil Lockwood
Phil Lockwood

Reputation: 21

On Lion, I was able to install gcc 4.7 using brew. I don't know if it will work on snow leopard.

You can try to install it from the homebrew-dupes container:

brew install --use-llvm --enable-cxx https://raw.github.com/Homebrew/homebrew-dupes/master/gcc.rb

Compiled gcc 4.7 successfully with c and c++ enabled on Lion.

Upvotes: 0

jer
jer

Reputation: 20236

You...don't. GNU's GCC is not compatible with Apple's GCC in terms of Objective-C runtime support. You'll get the GNU Objective-C runtime which is the compatibility problem.

My strong suggestion to you is to not use C++0x features until the new standard is...a standard, and not a draft. Don't expect compiler support for draft features on all platforms.

Upvotes: 2

Related Questions