0

安装了 GCC 4.7,但我的 mac 目前使用的是 4.2。我该如何切换它?

一些可能有帮助的细节:

操作系统:狮子 10.7.5

海湾合作委员会:4.2.1

GCC 4.2.1 的路径:/usr/bin/gcc

GCC 4.7 的路径:/usr/local/bin/gcc-4.7

4

1 回答 1

0

将 GCC 4.8 安装到 Xcode 4.5、Xcode 4.6、Xcode 5.0 中:

对于尚未安装 GCC 4.8 的人:

安装新版本的自制软件

你可以在网上找到如何安装的方法

将您的 brew 更新到最新版本 ( $brew update)

1.$brew install gcc48 --enable-all-languages

(可能应该通过 brew 安装 mpc、mpfr 和 gmp,http ://solarianprogrammer.com/2013/06/11/compiling-gcc-mac-os-x/ )

2.$brew link gcc48

3.备份g++,gpp,c++,cpp,c++ in/usr/bin/

4.【可选步骤】:

别名 g++-4.8,gpp-4.8,c++-4.8,cpp-4.8,c++-4.8

/usr/local/Cellar/gcc48/4.8.2/bin/g++

/usr/bin/

【以上4步,未安装gcc的开发者】

[@“Donny P”:以上4步可以跳过]

5.制作插件

1) 为Xcode下载一个GCC 4.5插件

2)将每个“4.5”更改为“4.8”,将“4_5”更改为“4_8”,文件名,文件内容,

除了文件中的“com.apple.compilers.gcc.headers.4_2” GCC 4.5.xcspec

您可以保持内容English.lproj不变,并删除Japanese.lproj.

3)在文件中GCC 4.8.xcspec

(希望您已经将文件名更改GCC 4.5.xcspecGCC 4.8.xcspec

改变ExecPath = "...”;

to ExecPath = "/usr/local/bin/gcc-4.8"(@"Donny P": 你可以把它改成 "/usr/local/bin/gcc-4.7")

ExecPath = "/usr/local/Cellar/gcc48/4.8.2/bin/gcc-4.8"(对于通过 brew 安装 gcc-4.8 的人)

ExecPath = "/usr/bin/gcc"(对于完成第 4 步的人。)

4)删除文件中的“-Wshorten-64-to-32”部分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.把编辑GCC 4.8.xcplugin

/Applications/Xcode.app/Contents/Plugins/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/

7.重新打开Xcode。

现在,新插件已经为您准备好了。您可以在项目的“Build Settings”的“Compiler for C/C++/Objective-C”中看到新的 GCC 编译器插件

8.更改Xcode项目中的构建设置

1)在Xcode的projectand设置中target

将“C/C++/Objective-C 编译器”更改为“GCC 4.8”

2)在project设置中

删除“CLANG_CXX_LIBRARY”行

于 2013-10-18T05:24:20.687 回答