如何在Xcode 4.2中使用gcc 4.2 [英] How to use gcc 4.2 with Xcode 4.2
问题描述
对于一些较旧的代码,我需要使用带有Xcode 4.2的gcc 4.2。我如何让它显示
。 Xcode4.2似乎已经放弃了对它的支持。
谢谢
这是一种在 xcode 4.2 中使用 gcc 4.2 进行编译的方法。这主要是通过命令行完成的,所以当你看到以 [15:30 jon @MacBookPro /] $
开头的行时,你需要打开 Terminal.app 并运行在 $
之后开始的命令。
否在此过程中,文件或目录被删除或已删除,因此如果您将来需要使用LLVM进行编译,则很容易撤消。
-
下载 - 但不安装尚未 -
[1] 如果从命令行打开(使用类似
vi
,emacs
,nano
等)确保将路径括在引号/ long path / with spaces / in / file.xcspec或转义空格 / some / long \ path / with\ spaces / in\ it / file.xcspec
[2] 这是必要的,因为iPhoneOS.platform SDK有自己独立的
/ usr / lib
目录,但iPhoneSimulator.platform SDK不是I need to use gcc 4.2 with Xcode 4.2 for some older code. How do i get it to show up. Xcode4.2 seems to have dropped support for it.
Thanks
解决方案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.
Download - but do not install yet - xcode_4.1_for_lion.dmg or xcode_4.1_for_snow_leopard.dmg
Now, follow these steps to install Xcode 4.1 into
/Developer-4.1
:Backup the working
/Developer
directory (where Xcode 4.2 is installed)
[ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.2
Run the Xcode 4.1 installer using the default install location (
/Developer
)Move the new Xcode 4.1 installation to
/Developer-4.1
:[ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.1
Move the Xcode 4.2 developer directory back to
/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]:[ 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;
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
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
Copy the
gcc
andinfo
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
Compile using gcc-4.2!
[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中使用gcc 4.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!