Expedite progress – think in the future, become estranged from the now.

  • >
  • articles
  • xcode-42-and-c-11
  • 2016-02-16

    02:58:45

    XCode 4.2 and C++11

      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:

      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 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 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!