[英]No gcc 4.2 compiler option in Xcode 4?
In my Xcode 4 installation, I only have 2 compiler options: 在我的Xcode 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. 在许多Xcode示例中,我看到GCC 4.2显示为第三个选项,但这根本不存在。 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?
我故意干净安装XCode 4.是否有标准的方法来添加GCC 4.2,如果它还没有? 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.
我的一个项目要求我使用GCC(而不是GCC LLVM),其他项目我对GCC LLVM感到满意,所以这只是一个问题。
Here is a way to enable compiling with gcc 4.2 in xcode 4.2 . 这是一种在xcode 4.2中使用gcc 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 $
. 这主要通过命令行完成,因此当您看到以
[ 15:30 jon@MacBookPro / ]$
开头的行时,您需要打开Terminal.app并运行在$
后面开始的命令。
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.
在此过程中不会删除或删除任何文件或目录,因此如果您将来需要使用LLVM进行编译,则很容易撤消。
Download - but do not install yet - xcode_4.1_for_lion.dmg or xcode_4.1_for_snow_leopard.dmg 下载-但是不要安装尚未 - xcode_4.1_for_lion.dmg或xcode_4.1_for_snow_leopard.dmg
Now, follow these steps to install Xcode 4.1 into /Developer-4.1
: 现在,按照以下步骤将Xcode 4.1安装到
/Developer-4.1
:
Backup the working /Developer
directory (where Xcode 4.2 is installed) 备份working
/Developer
目录(安装Xcode 4.2的地方)
[ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.2
Run the Xcode 4.1 installer using the default install location ( /Developer
) 使用默认安装位置(
/Developer
)运行Xcode 4.1安装程序
Move the new Xcode 4.1 installation to /Developer-4.1
: 将新的Xcode 4.1安装移至
/Developer-4.1
:
[ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.1
Move the Xcode 4.2 developer directory back to /Developer
: 将Xcode 4.2开发人员目录移回
/Developer
:
[ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer-4.2 /Developer
Edit the Xcode 4.2 GCC 4.2.xcspec
file to get gcc 4.2 to show in the list of compiler options [1] : 编辑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/Plug-ins/GCC 4.2 (Plausible Blocks).xcplugin/Contents/Resources/GCC 4.2.xcspec"
Change lines 41 and 42 from this: 从这里改变第41和42行:
ShowInCompilerSelectionPopup = NO; IsNoLongerSupported = YES;
To This: 对此:
ShowInCompilerSelectionPopup = YES; IsNoLongerSupported = NO;
Backup the Xcode 4.2 iOS/Simulator Framework usr
directories: 备份Xcode 4.2 iOS / Simulator Framework
usr
目录:
[ 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
Copy Xcode 4.1 iOS/Simulator Framework usr
directories to Xcode 4.2: 将Xcode 4.1 iOS / Simulator Framework
usr
目录复制到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
Copy the gcc
and info
iOS SDK library directories from Xcode 4.1 to Xcode 4.2 [2] : 将
gcc
和info
iOS SDK库目录从Xcode 4.1复制到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
Compile using gcc-4.2! 使用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 [1]如果从命令行打开(使用类似
vi
, emacs
, nano
等的东西),请确保将路径括在引号“/ long path / with spaces / in / file.xcspec”中,或者转义空格/ 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 [2]这是必要的,因为iPhoneOS.platform SDK有自己的单独的
/usr/lib
目录,但iPhoneSimulator.platform SDK没有
Xcode 4.3 has a specific folder /Applications/Xcode.app/Contents/Developer/Toolchains
. Xcode 4.3有一个特定的文件夹
/Applications/Xcode.app/Contents/Developer/Toolchains
。
Is there a way to add other tool-chains as AVR-gcc and PIC32-gcc? 有没有办法添加其他工具链作为AVR-gcc和PIC32-gcc?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.