简体   繁体   English

设置环境变量以使用XCode4.4在Mountain Lion上编译节点

[英]Setting environment variables to compile node on Mountain Lion with XCode4.4

After upgrading to Mountain Lion (10.8) and XCode 4.4, and installing the XCode Command Line utilities from the XCode Preferences pane, I was unable to compile node.js (0.8.5) from source. 升级到Mountain Lion(10.8)和XCode 4.4,并从“ XCode首选项”窗格安装XCode命令行实用程序后,我无法从源代码编译node.js(0.8.5)。 Specifically, the configure script believed that I did not have a C compiler installed. 具体来说,配置脚本认为我没有安装C编译器。

It looks to me like the environment variables required for the command line tools were lost somewhere along the way. 在我看来,命令行工具所需的环境变量在整个过程中都丢失了。

I tried sudo xcode-select --switch /Applications/Xcode.app but this did not appear to clear up the problem. 我尝试了sudo xcode-select --switch /Applications/Xcode.app但这似乎并没有解决问题。

I had to perform these steps to make the node build system happy: 我必须执行以下步骤才能使节点构建系统满意:

  • export PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin
  • export CC='gcc --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/'
  • export CXX='g++ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/'

After that I was able to compile and link. 之后,我可以进行编译和链接。

So... why did I have to do this? 那么...我为什么要做这个? Am I missing some easy step that could have done this for me automatically? 我是否缺少一些可以自动为我完成此操作的简单步骤? Or am I in some bad state because I installed XCode before upgrading to Mountain Lion, and the XCode updater went off the rails? 还是因为升级到Mountain Lion之前安装了XCode以及XCode更新器脱离正常状态而使我处于某种糟糕的状态?

Once you've updated to Mountain Lion and updated XCode 4.4, you have to reinstall the command line tools inside XCode. 一旦更新到Mountain Lion并更新了XCode 4.4,就必须在XCode内部重新安装命令行工具。

Go to XCode/Preferences/Downloads/Components and click install on "Command Line Tools" and once it has downloaded and installed, you should once again have gcc and g++ in your (normal) path. 转到XCode / Preferences / Downloads / Components,然后在“命令行工具”上单击安装,一旦下载并安装了它,(正常)路径中应该再次包含gcc和g ++。

The correct thing to do was to reinstall the command-line tools from inside Xcode. 正确的做法是从Xcode内部重新安装命令行工具。

This was temporarily impossible because a malformed download list was being served by Apple, but the problem was fixed. 这暂时是不可能的,因为Apple正在提供格式错误的下载列表,但此问题已解决。 The malformation was detectable by inspecting the output from Xcode in Console. 通过检查Console中Xcode的输出可以检测到格式错误。

Once the tools were reinstalled, compilation worked normally. 重新安装工具后,编译即可正常进行。

http://docwiki.embarcadero.com/RADStudio/XE4/en/Installing_the_Xcode_Command_Line_Tools_on_a_Mac http://docwiki.embarcadero.com/RADStudio/XE4/en/Installing_the_Xcode_Command_Line_Tools_on_a_Mac

Please refer the above link and try to install command line from apple developer portals 请参考上面的链接,并尝试从Apple开发人员门户网站安装命令行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM