Using gcc on OS/X


I must use gcc on OS/X for my project, because clang doesn't have some features I require.

I am trying to get JUCE to compile using gcc, without any success, and I'm not familiar enough with OS/X quirks to know what direction to go.


Has anyone successfully compiled JUCE on OS/X using gcc?  Or alternatively, has anyone been able to compile JUCE as a dylib (or .a) with the default setup, and link to it with a gcc compiled app?




AFAIK everything in juce itself should be fine in either compiler - if you find something that isn't, let me know.

Whether all the latest Apple libs and headers still work with GCC is another question though - I've no idea whether they still support that.


Hello, Jules -

I thought perhaps upgrading gcc might help, but alas it doesn't.  I'm using the 'brew' version of gcc-4.9.

Using g++-4.9, with the options "-std=c++0x -shared -mtune=native -march=core2 -fPIC -ffixed-r15 -D JUCE_MAC -D "MAC=1" -D "NDEBUG=1" -D "JUCE_APP_VERSION=1.0.0" -D "JUCE_APP_VERSION_HEX=0x10000" -I /usr/include -I /usr/include/freetype2 -I ../../JuceLibraryCode -I ../../JuceLibraryCode/modules"

I see errors like:

Compiling juce_core.cpp
In file included from ../../JuceLibraryCode/modules/juce_core/juce_core.cpp:43:0:
../../JuceLibraryCode/modules/juce_core/native/juce_BasicNativeHeaders.h:47:4: warning: #import is a deprecated GCC extension [-Wdeprecated]
   #import <Cocoa/Cocoa.h>
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:8:0,
                 from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12,
                 from ../../JuceLibraryCode/modules/juce_core/native/juce_BasicNativeHeaders.h:47,
                 from ../../JuceLibraryCode/modules/juce_core/juce_core.cpp:43:
/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:409:1: error: stray '@' in program
 @class NSString, Protocol;

...many more such lines...

In file included from /System/Library/Frameworks/ApplicationServices.framework/Frameworks/ATS.framework/Headers/ATSLayoutTypes.h:24:0,
                 from /System/Library/Frameworks/ApplicationServices.framework/Frameworks/ATS.framework/Headers/ATS.h:28,
                 from /System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:28,
                 from /System/Library/Frameworks/Foundation.framework/Headers/NSAppleEventDescriptor.h:7,
                 from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:138,
                 from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12,
                 from ../../JuceLibraryCode/modules/juce_core/native/juce_BasicNativeHeaders.h:47,
                 from ../../JuceLibraryCode/modules/juce_core/juce_core.cpp:43:
/System/Library/Frameworks/ApplicationServices.framework/Frameworks/ATS.framework/Headers/SFNTLayoutTypes.h:30:22: error: expected declaration before end of line
 #pragma pack(push, 2)


I'm hoping the problem is just command-line parameters to the compiler... any ideas?


Sorry, I don't know much about GCC's command-line params.

#import is an obj-C thing, which will obviously need to be enabled to use the OSX system calls, but I don't know how you'd do that.


You need to use the "-ObjC++" parameter, so that it activates support for obj-c++



thanks anyway


That only works with the gcc included in OS/X, which is a clang/LLVM version, and doesn't support some of the features I need.

Thanks for the feedback