xcode - 如何在 Xcode 5 中使用最近的 GCC?

标签 xcode macos gcc

Apple 完全删除了他们曾经拥有的任何 GCC 支持。有没有办法在 Xcode 5 中使用最近的 GCC(比如 4.8)?换句话说,在 Xcode 中使用 GCC 代替 LLVM。

最佳答案

将 GCC 4.8 安装到 Xcode 4.5、Xcode 4.6、Xcode 5.0:
对于尚未安装 GCC 4.8 的人:
安装新版本的 home-brew
你可以在网上找到如何安装的方法
将您的 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 gcc483.备份 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的开发者】
5.制作插件
1)下载a plugin of GCC 4.5 for Xcode
2)将每个“4.5”更改为“4.8”,将“4_5”更改为“4_8”,文件名,文件内容,
除了文件 GCC 4.5.xcspec 中的“com.apple.compilers.gcc.headers.4_2”。
您可以在 English.lproj 中保留内容不变,删除Japanese.lproj .
3) 在文件中 GCC 4.8.xcspec(希望您已经将 GCC 4.5.xcspec 的文件名更改为 GCC 4.8.xcspec )
ExecPath = "...”;ExecPath = "/usr/local/bin/gcc-4.8"ExecPath = "/usr/local/Cellar/gcc48/4.8.2/bin/gcc-4.8" (对于通过 brew 安装 gcc-4.8 的人)
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.put 编辑 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项目中的Build Settings
1)在projecttarget Xcode 中的设置
将“C/C++/Objective-C 编译器”更改为“GCC 4.8”
2)在project设置
删除“CLANG_CXX_LIBRARY”行

关于xcode - 如何在 Xcode 5 中使用最近的 GCC?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19061966/

相关文章:

使用 exec() 编译和运行 c 程序

c++ - 在 C++ 头文件上检查操作系统时出错

ios - `Debug navigator` 面板中的 XCode 内存分析显示 `CPU usage` 高于 100%

ios - 部署后向 App-Info.plist 添加值

gcc - 使用 YDL 6.1 和 Cell SDK 3.1 的 PS3 上的 math.h 未定义对 'sqrt' 的引用?

macos - grpc make 找不到协议(protocol) 3

javascript - 错误!安装无法读取 mac 上的依赖项

ios - 如何区分 wR hR 约束变化的方向

objective-c - 以编程方式调用 Storyboard 场景(无需转场)?

c - while 循环中 "fgets"的意外行为