问题
I've been through almost every page and all the tips don't fix the problem. I'm running Mountain Lion I've got Xcode, all the latest developer tools the latest GCC and everything. I am trying to set up rbenv and ruby-build. Everything seems to work but when I go to install a version of ruby it says that the c compiler doesn't work and that it can't create executables. The exact last lines of the log:
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for gcc... /usr/bin/gcc-4.2
checking whether the C compiler works... no
configure: error: in `/var/folders/zr/gv4jcc_122sfrtpfj5g9prc00000gn/T/ruby-build.20130106144331.1477/yaml-0.1.4':
configure: error: C compiler cannot create executables
I'm stumped. The log contains:
configure:3265: /usr/bin/gcc-4.2 -I'/Volumes/Macintosh HD 2/Users/jmart/.rbenv/versions/1.9.3-p327/include' -L'/Volumes/Macintosh HD 2/Users/jmart/.rbenv/versions/1.9.3-p327/lib' conftest.c >&5
i686-apple-darwin11-gcc-4.2.1: HD: No such file or directory
i686-apple-darwin11-gcc-4.2.1: 2/Users/jmart/.rbenv/versions/1.9.3-p327/include': No such file or directory
i686-apple-darwin11-gcc-4.2.1: HD: No such file or directory
i686-apple-darwin11-gcc-4.2.1: 2/Users/jmart/.rbenv/versions/1.9.3-p327/lib': No such file or directory
configure:3269: $? = 1
configure:3307: result: no
UPDATE:: Noticing the "HD: No such..." & "2" No Such... I do have two two Drives installed in my mac - one for user files and one for sys files. Is that what's throwing the error here?
回答1:
It looks like a bug in the configure script, but there is no need to rename the volume; just make a symbolic link. I don't have a Mac, but something like this should do it (as root):
cd /Volumes
ln -s 'Macintosh HD2' MacHD2
Then:
./configure --prefix=/Volumes/MacHD2/Users/jmart/.rbenv/versions/1.9.3-p327
回答2:
Spaces must be escaped.
$ pwd
/Volumes/VMware Shared Folders/userdata/...
Typing cd
and copy-pasting :
$ cd /Volumes/VMware Shared Folders/userdata
-bash: cd: /Volumes/VMware: No such file or directory
$ cd /Volumes/VMware\ Shared\ Folders/userdata/
...:userdata ba$
In case of cd
, using tab completion automatically adds the backslash-space.
来源:https://stackoverflow.com/questions/14182791/c-compiler-cannot-create-executables-on-mac-os-mountain-lion