78 lines
3.3 KiB
Plaintext
78 lines
3.3 KiB
Plaintext
[[toc]]
|
|
|
|
## Preface
|
|
This brief guide comes as a result of requiring C++11 support under a Dell Latitude D620 with only Mac OS 10.6.8 peasantry.
|
|
|
|
Special thanks to those who initially wrote information regarding these processes:
|
|
* [How to use a recent GCC with Xcode 5? answer](http://stackoverflow.com/a/19442587) -- **frogcjn**
|
|
* [Integrating GCC 4.4 to Xcode (MacOS/Snow Leopard) ](http://skurganov.blogspot.com/) -- **Sergey Kurganov**
|
|
|
|
## Stage 1. Install GCC 4.8 from Homebrew
|
|
For this process, we'll be using Homebrew -- alternatives like macports or manual compilation can be adapted to work as well.
|
|
|
|
brew update
|
|
brew install homebrew/versions/gcc48 --with-all-languages
|
|
|
|
## Stage 2. Link in new GCC 4.8
|
|
For this stage, I opted to keep a similar feel as per the standard GCC versions in /usr/bin, such as /usr/bin/gcc-4.0:
|
|
|
|
ln -sf /usr/local/Cellar/gcc48/4.8.5/bin/g++-4.8 /usr/bin/g++-4.8
|
|
ln -sf /usr/local/Cellar/gcc48/4.8.5/bin/c++-4.8 /usr/bin/c++-4.8
|
|
ln -sf /usr/local/Cellar/gcc48/4.8.5/bin/gcc-4.8 /usr/bin/gcc-4.8
|
|
ln -sf /usr/local/Cellar/gcc48/4.8.5/bin/ccp-4.8 /usr/bin/cpp-4.8
|
|
|
|
Thereafter we can link the system gcc/g++/etc. binaries to the new 4.8 versions:
|
|
|
|
ln -sf /usr/bin/g++-4.8 /usr/bin/g++
|
|
ln -sf /usr/bin/c++-4.8 /usr/bin/c++
|
|
ln -sf /usr/bin/gcc-4.8 /usr/bin/gcc
|
|
vi /usr/bin/cpp
|
|
line 51: CPP="gcc-4.8 -E"
|
|
|
|
[](gcc4.8.5.png)
|
|
|
|
## Stage 3. Install/Create XCode GCC 4.8 plugin
|
|
At this point we need a GCC 4.8 compiler plugin for XCode.
|
|
|
|
Your first option is to download this [zip file](/files/GCC%204.8.xcplugin.zip) and extract it to:
|
|
|
|
/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins
|
|
|
|
Your second option is to use the following steps (terminal-centric):
|
|
|
|
cd /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins
|
|
cp -rfpv GCC\ 4.2.xcplugin GCC\ 4.8.xcplugin
|
|
cd GCC\ 4.8.xcplugin/Contents/
|
|
plutil -convert xml1 Info.plist
|
|
vi Info.plist
|
|
line 10: <string>com.apple.xcode.compilers.gcc.4_8</string>
|
|
line 14: <string>GCC 4.8 Compiler Xcode Plug-in</string>
|
|
plutil -convert binary1 Info.plist
|
|
cd Resources
|
|
mv GCC\ 4.2.xcspec GCC\ 4.8.xcspec
|
|
vi GCC\ 4.8.xcspec
|
|
line 10: Identifier = "com.apple.compilers.gcc.4_8";
|
|
line 13: Name = "GCC 4.8";
|
|
line 14: Description = "GNU C/C++ Compiler 4.8";
|
|
line 16: Version = "4.8";
|
|
line 38: ExecPath = "/usr/bin/gcc-4.8"
|
|
line 41: ShowInCompilerSelectionPopup = YES;
|
|
line 42: IsNoLongerSupported = NO;
|
|
line 252: DefaultValue = NO;
|
|
line 876: DefaultValue = NO;
|
|
line 1016: DefaultValue = NO;
|
|
cd English.lproj
|
|
mv GCC\ 4.2.strings GCC\ 4.8.strings
|
|
vi GCC\ 4.8.strings
|
|
line 11: "Name" = "GCC 4.8";
|
|
line 12: "Description" = "GNU C/C++ Compiler 4.8";
|
|
line 13: "Version" = "4.8";
|
|
|
|
Reload XCode and select **GCC 4.8** under *Build Settings -> Build Options -> Compiler for C/C++/Objective-C*.
|
|
|
|
**Congratulations**, you can now compile with GCC 4.8!
|
|
|
|
Even more fun, you now have C++11 at your disposal by setting **--std=c++11** under *Build Settings -> GCC 4.8 - Language -> Other C++ Flags*
|
|
|
|
**Even More Congratulations**, you can now compile with lamdas!
|