在Xcode 4.2和iOS SDK 5.0中使用gcc 4.2 [英] Use gcc 4.2 in Xcode 4.2 and iOS SDK 5.0

查看:222
本文介绍了在Xcode 4.2和iOS SDK 5.0中使用gcc 4.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚升级到Xcode 4.2和iOS SDK 5今天早些时候。



现在有两个C / C ++ / Objective-C编译器选项,Apple LLVM编译器3.0和LLVM GCC 4.2。 GCC 4.2缺失。



Apple LLVM编译器3.0,构建速度非常快(我喜欢),给我999个警告,我的游戏不能再运行。



LLVM GCC 4.2是那么神的慢,我仍然不能完成一个构建后,小时在我的i7机器上。



还有一件事是我们的引擎使用gcc命令行来构建(而不是xcode)。



因此,它会导致一个问题,如何在Xcode 4.2中使用gcc 4.2 ?这是可能的吗?

解决方案


下面是一个使用 中 。大部分是通过命令行完成的,所以当你看到这样的行: [15:30 jon @ MacBookPro /] $ ,你需要打开一个终端并在 $ 后运行该命令。


目录在此过程中被删除 已删除,所以如果需要在将来使用LLVM编译时很容易撤消。


< blockquote>


  1. 下载 - 但安装 - 。






    [1] 如果从命令行打开(使用 vi emacs nano 等)确保用引号将路径引用/ long path / with spaces / in / file.xcspec kbd>或转义空格 / some / long\ path / with\ spaces / in \ it / file.xcspec



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


    I just upgraded to Xcode 4.2 and iOS SDK 5 earlier today. But everything seems different with new compilers.

    There are two "Compiler for C/C++/Objective-C" options now, "Apple LLVM compiler 3.0" and "LLVM GCC 4.2". GCC 4.2 is missing.

    Apple LLVM compiler 3.0, builds really fast(I like that), gives me 999+ warnings, and my game can no longer run. It looks like there's some differences on memory, and it crashes when loading our game's scripts.

    LLVM GCC 4.2 is so god damn slow, I still cannot finish one build after hours on my i7 machine.

    And, one more thing is our engine uses gcc command lines to build(instead of xcode).

    So, it leads to one question, how can I use gcc 4.2 in Xcode 4.2? Is that even possible?

    解决方案

    Here is a way to enable compiling with gcc 4.2 in xcode 4.2. Most of this is done via command line so when you see lines like this: [ 15:30 jon@MacBookPro / ]$, you need to open up a Terminal and run the command 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!


    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

    这篇关于在Xcode 4.2和iOS SDK 5.0中使用gcc 4.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆