install GCC 4.8 into Xcode 4.5, Xcode 4.6, Xcode 5.0:
for people who have not install GCC 4.8:
install the new version of home-brew
you can find the method how to install on the Internet
update your brew to the latest version ($brew update
)
1.brew install gcc48 --enable-all-languages
(may should install mpc, mpfr and gmp through brew, http://solarianprogrammer.com/2013/06/11/compiling-gcc-mac-os-x/)
2.$brew link gcc48
3.backup g++,gpp,c++,cpp,c++ in /usr/bin/
4.[optional step]:
alias g++-4.8,gpp-4.8,c++-4.8,cpp-4.8,c++-4.8
from /usr/local/Cellar/gcc48/4.8.2/bin/g++
to /usr/bin/
[above 4 steps for the developer who have not install gcc]
5.make plugin
1)download a plugin of GCC 4.5 for Xcode
2)change every "4.5" to "4.8", "4_5" to "4_8", the file names, the file contents,
except "com.apple.compilers.gcc.headers.4_2” in the file GCC 4.5.xcspec
.
you can remain contents in English.lproj
unchanged, and delete Japanese.lproj
.
3)in file GCC 4.8.xcspec
(hope you have already change the file name of GCC 4.5.xcspec
to GCC 4.8.xcspec
)
change ExecPath = "...”;
to ExecPath = "/usr/local/bin/gcc-4.8"
or ExecPath = "/usr/local/Cellar/gcc48/4.8.2/bin/gcc-4.8"
(for the people who install gcc-4.8 by brew)
4)delete “-Wshorten-64-to-32” part in file GCC 4.8.xcspec
{
Name = "GCC_WARN_64_TO_32_BIT_CONVERSION";
Type = Boolean;
DefaultValue = NO;
CommandLineArgs = {
YES = (
"-Wshorten-64-to-32",
);
NO = ();
};
AppearsAfter = "GCC_WARN_PROTOTYPE_CONVERSION";
Category = Warnings;
CommonOption = NO;
DisplayName = "Implicit Conversion to 32 Bit Type";
Description = "Warn if a value is implicitly converted from a 64 bit type to a 32 bit type.
[GCC_WARN_64_TO_32_BIT_CONVERSION, -Wshorten-64-to-32]";
}
6.put edited GCC 4.8.xcplugin
into
/Applications/Xcode.app/Contents/Plugins/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/
7.reopen Xcode.
Now, the new plugin has already prepared for you. You can see your new GCC compiler plugin in the "Compiler for C/C++/Objective-C" of "Build Settings" of your project
8.change Build Settings in Xcode project
1)In the project
and target
settings in Xcode
change "Compiler for C/C++/Objective-C" to "GCC 4.8"
2)In the project
settings
delete “CLANG_CXX_LIBRARY" row