How to move GCC in osx from xcode to /usr/bin

痴心易碎 提交于 2019-12-09 21:05:11

问题


I have the gcc compiler in "/Developer/usr/bin/gcc" but when i type in gcc into terminal it says can not be found, i assume this is because its not in the "/usr/bin" dir. So can i a) move gcc from the first dir to the second, or set some kind of shortcut pointing gcc to "/Developer/usr/bin/gcc"


回答1:


Two choices:

  1. Edit your ~/.bashrc or ~/.bash_profile (or equivalent system files) and add /Developer/usr/bin/gcc to $PATH: export PATH="$PATH:/Developer/usr/bin/"
  2. Create a link (symlink in this example) in your /usr/bin directory pointing to the real file: ln -s /Developer/usr/bin/gcc /usr/bin/gcc

Note: in XCode 4.5 on MacOS 10.8 the path is now: /Applications/Xcode.app/Contents/Developer/usr/bin




回答2:


The tip thewoolleyman linked to worked for me! I have installed Xcode 4.3.3 via the App Store. I did not have to install Xcode "again", seems Apple solved that. What I had to do are the following easy steps:

  1. Open Xcode
  2. Go To Preferences > Downloads
  3. Install the Command Line Tools

Thanks to Guy and his post https://stackoverflow.com/a/9377095/1451903




回答3:


Use ln -s to create a symlink in /usr/bin, or add /Developer/usr/bin to $PATH.




回答4:


You can, in theory, hardlink it to the proper place.

The official way to do this is to install the optional "command-line tools" with the XCode installer. This wastes several hundred megabytes as it installs a new copy of the same compiler.

I wrote a shell script once to compare the installation trees of the "XCode" installation and the "command-line" installation and hardlink together all the files that were identical. It worked perfectly but the next upgrade undid it.

Another alternative is to download the GCC source from their CVS (not much bigger than downloading the massive XCode installer), and build it into usr/bin/ yourself. Then you have the latest and greatest (or your choice of many newer and better versions) to play with.




回答5:


If you have "installed" Xcode from the App Store, check out this thread:

Mac OS X Lion Xcode problems using RVM

Apparently, "installing" Xcode from the app store doesn't actually install it, you must manually run the installer (search for "Install Xcode" in spotlight).



来源:https://stackoverflow.com/questions/3972382/how-to-move-gcc-in-osx-from-xcode-to-usr-bin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!