Xcode 4 中没有 gcc 4.2 编译器选项?

发布于 2024-12-06 05:21:29 字数 273 浏览 2 评论 0原文

在我的 Xcode 4 安装中,我只有 2 个编译器选项:

  1. Apple LLVM 编译器 3.0
  2. GCC LLVM 4.2

在许多 Xcode 示例中,我看到 GCC 4.2 显示为第三个选项,但这根本不存在。我特意对 XCode 4 进行了全新安装。如果 GCC 4.2 尚不存在,是否有添加 GCC 4.2 的标准方法?我的一个项目要求我使用 GCC(而不是 GCC LLVM),其他项目我对 GCC LLVM 很满意,所以这只是该项目的一个问题。

In my Xcode 4 installation, I only have 2 compiler options:

  1. Apple LLVM compiler 3.0
  2. GCC LLVM 4.2

In many Xcode examples I have seen that GCC 4.2 is shown as a third option, but this simply isn't there. I intentionally did a clean installation of XCode 4. Is there a standard method for adding GCC 4.2 if it's not already there? One of my projects requires that I use GCC (and not GCC LLVM), the other projects I am happy with GCC LLVM, so it's only an issue for that one.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷鸟归林 2024-12-13 05:21:29

这是一种在 xcode 4.2 中启用 gcc 4.2 编译的方法。这主要是通过命令行完成的,因此当您看到以以下开头的行时:[ 15:30 jon@MacBookPro / ]$,您需要打开Terminal.app并运行在 $ 之后开始的命令。

在此过程中不会删除删除任何文件或目录,因此如果您将来需要使用 LLVM 进行编译,可以轻松撤消。

  1. 下载 - 但暂时不要安装 - xcode_4.1_for_lion.dmgxcode_4.1_for_snow_leopard.dmg< /p>

  2. < p>现在,按照以下步骤将 Xcode 4.1 安装到/Developer-4.1

    1. 备份工作 /Developer 目录(安装 Xcode 4.2 的位置)

    2. [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.2
      
    3. 使用默认安装位置 (/Developer) 运行 Xcode 4.1 安装程序

    4. 将新的 Xcode 4.1 安装移至 /Developer-4.1

      [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.1
      
    5. 将 Xcode 4.2 开发人员目录移回 /Developer

      [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer-4.2 /Developer
      
  3. 编辑 Xcode 4.2 GCC 4.2.xcspec 文件以获取 gcc 4.2在编译器选项列表中显示[1]

    [ 15:30 jon@MacBookPro / ]$ sudo vi "/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/ Xcode/插件/GCC 4.2(合理块).xcplugin/Contents/Resources/GCC 4.2.xcspec"
    
    • 4142 行从此更改:

      ShowInCompilerSelectionPopup = NO;
      不再支持=是;
      
    • 致此:

      ShowInCompilerSelectionPopup = YES; 
      不再支持=否;
      
  4. 备份 Xcode 4.2 iOS/Simulator Framework usr 目录:

    [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS.platform /开发者/usr.backup
    [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneSimulator.platform/Developer/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr.backup
    
  5. 将 Xcode 4.1 iOS/Simulator Framework usr 目录复制到 Xcode 4.2:< /p>

    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS .platform/开发者/usr
    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr
    
  6. 复制 gccinfo从 Xcode 4.1 到 Xcode 4.2 的 iOS SDK 库目录[2]

    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk /usr/lib/gcc /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/gcc
    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/info /Developer/Platforms/iPhoneOS.platform/Developer /SDKs/iPhoneOS5.0.sdk/usr/lib/info
    
  7. 使用gcc-4.2编译!

    xcode 4.2 中 CGG 4.2 的屏幕截图

这是一个我写的博客文章提供了有关此过程的更多信息。如果您遇到任何问题或有任何疑问,请随时在博客上发表评论。


[1] 如果从命令行打开(使用类似 viemacsnano 等)确保将路径用引号括起来 "/long path/with space/in it/ file.xcspec" 或转义空格/some/long\ path/with\spaces/in\ it/file.xcspec

[2] 这是必要的,因为 iPhoneOS.platform SDK 有自己的单独的 /usr/lib 目录,但 iPhoneSimulator.platform SDK 没有

Here is a way to enable compiling with gcc 4.2 in xcode 4.2. This is mostly done via command line so when you see lines starting with: [ 15:30 jon@MacBookPro / ]$, you need to open up Terminal.app and run the command that starts after the $.

No files or directories are removed or deleted in this process, so it is easy to undo if you need to compile with LLVM in the future.

  1. Download - but do not install yet - xcode_4.1_for_lion.dmg or xcode_4.1_for_snow_leopard.dmg

  2. Now, follow these steps to install Xcode 4.1 into /Developer-4.1:

    1. Backup the working /Developer directory (where Xcode 4.2 is installed)

    2. [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.2
      
    3. Run the Xcode 4.1 installer using the default install location (/Developer)

    4. Move the new Xcode 4.1 installation to /Developer-4.1:

      [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.1
      
    5. Move the Xcode 4.2 developer directory back to /Developer:

      [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer-4.2 /Developer
      
  3. Edit the Xcode 4.2 GCC 4.2.xcspec file to get gcc 4.2 to show in the list of compiler options [1]:

    [ 15:30 jon@MacBookPro / ]$ sudo vi "/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/GCC 4.2 (Plausible Blocks).xcplugin/Contents/Resources/GCC 4.2.xcspec"
    
    • Change lines 41 and 42 from this:

      ShowInCompilerSelectionPopup = NO;
      IsNoLongerSupported = YES;
      
    • To This:

      ShowInCompilerSelectionPopup = YES; 
      IsNoLongerSupported = NO;
      
  4. Backup the Xcode 4.2 iOS/Simulator Framework usr directories:

    [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS.platform/Developer/usr.backup
    [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneSimulator.platform/Developer/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr.backup
    
  5. Copy Xcode 4.1 iOS/Simulator Framework usr directories to Xcode 4.2:

    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS.platform/Developer/usr
    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr
    
  6. Copy the gcc and info iOS SDK library directories from Xcode 4.1 to Xcode 4.2 [2]:

    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/gcc /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/gcc
    [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/info /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/info
    
  7. Compile using gcc-4.2!

    Screenshot of CGG 4.2 in xcode 4.2

This is a blog post I've written with a little more info about this process. Feel free to leave a comment on the blog if you run into any issues or have any questions.


[1] If opening from a command line (using something like vi, emacs, nano, etc) make sure to either enclose the path in quotes "/long path/with spaces/in it/file.xcspec" or escape the spaces /some/long\ path/with\ spaces/in\ it/file.xcspec

[2] This is necessary because the iPhoneOS.platform SDK has its own seperate /usr/lib directories but the iPhoneSimulator.platform SDK does not

ゃ人海孤独症 2024-12-13 05:21:29

Xcode 4.3 有一个特定的文件夹 /Applications/Xcode.app/Contents/Developer/Toolchains

有没有办法添加其他工具链,如 AVR-gcc 和 PIC32-gcc?

Xcode 4.3 has a specific folder /Applications/Xcode.app/Contents/Developer/Toolchains.

Is there a way to add other tool-chains as AVR-gcc and PIC32-gcc?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文