macos 配置:错误:C 编译器无法创建可执行文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10357804/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
configure: error: C compiler cannot create executables
提问by CourtDemone
I've checked a number of similar questions on stackoverflow but haven't found an answer yet.
我已经在 stackoverflow 上检查了许多类似的问题,但还没有找到答案。
I'm trying to install memcached on Lion OSX as shown here.
我正在尝试在 Lion OSX 上安装 memcached,如下所示。
Here's what I'm getting:
这是我得到的:
j-court-demones-macbook-pro:libevent-1.4.12-stable jcourtdemone$ ./configure; make
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
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... gcc
checking for C compiler default output file name...
configure: error: in `/tmp/libevent-1.4.12-stable':
configure: error: C compiler cannot create executables
See `config.log' for more details.
make: *** No targets specified and no makefile found. Stop.
I've reinstalled Xcode as was recommended in a couple places, but no dice.
我已经按照几个地方的建议重新安装了 Xcode,但没有骰子。
Here's my config.log:
这是我的 config.log:
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ ./configure
## --------- ##
## Platform. ##
## --------- ##
hostname = j-court-demones-macbook-pro.local
uname -m = x86_64
uname -r = 11.3.0
uname -s = Darwin
uname -v = Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64
/usr/bin/uname -p = i386
/bin/uname -X = unknown
/bin/arch = unknown
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo = Mach kernel version:
Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64
Kernel configured for up to 8 processors.
4 processors are physically available.
8 processors are logically available.
Processor type: i486 (Intel 80486)
Processors active: 0 1 2 3 4 5 6 7
Primary memory available: 4.00 gigabytes
Default processor set: 109 tasks, 599 threads, 8 processors
Load average: 0.98, Mach factor: 7.01
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
PATH: /opt/local/bin
PATH: /opt/local/sbin
PATH: /opt/local/bin
PATH: /opt/local/sbin
PATH: /usr/bin
PATH: /Developer/usr/bin
PATH: /usr/bin
PATH: /bin
PATH: /usr/sbin
PATH: /sbin
PATH: /usr/local/bin
PATH: /usr/X11/bin
## ----------- ##
## Core tests. ##
## ----------- ##
configure:2077: checking for a BSD-compatible install
configure:2145: result: /usr/bin/install -c
configure:2156: checking whether build environment is sane
configure:2199: result: yes
configure:2224: checking for a thread-safe mkdir -p
configure:2263: result: ./install-sh -c -d
configure:2276: checking for gawk
configure:2306: result: no
configure:2276: checking for mawk
configure:2306: result: no
configure:2276: checking for nawk
configure:2306: result: no
configure:2276: checking for awk
configure:2292: found /usr/bin/awk
configure:2303: result: awk
configure:2314: checking whether make sets $(MAKE)
configure:2336: result: yes
configure:2575: checking for gcc
configure:2591: found /Developer/usr/bin/gcc
configure:2602: result: gcc
configure:2834: checking for C compiler version
configure:2842: gcc --version >&5
i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5484)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
configure:2846: $? = 0
configure:2853: gcc -v >&5
Using built-in specs.
Target: i686-apple-darwin9
Configured with: /var/tmp/gcc/gcc-5484~1/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin9 --with-arch=apple --with-tune=generic --host=i686-apple-darwin9 --target=i686-apple-darwin9
Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5484)
configure:2857: $? = 0
configure:2864: gcc -V >&5
gcc-4.0: argument to `-V' is missing
configure:2868: $? = 1
configure:2891: checking for C compiler default output file name
configure:2913: gcc conftest.c >&5
ld: library not found for -lcrt1.10.5.o
collect2: ld returned 1 exit status
configure:2917: $? = 1
configure:2955: result:
configure: failed program was:
| /* confdefs.h. */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE "libevent"
| #define VERSION "1.4.12-stable"
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:2961: error: in `/tmp/libevent-1.4.12-stable':
configure:2964: error: C compiler cannot create executables
See `config.log' for more details.
## ---------------- ##
## Cache variables. ##
## ---------------- ##
ac_cv_env_CCC_set=
ac_cv_env_CCC_value=
ac_cv_env_CC_set=
ac_cv_env_CC_value=
ac_cv_env_CFLAGS_set=
ac_cv_env_CFLAGS_value=
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_CXXCPP_set=
ac_cv_env_CXXCPP_value=
ac_cv_env_CXXFLAGS_set=
ac_cv_env_CXXFLAGS_value=
ac_cv_env_CXX_set=
ac_cv_env_CXX_value=
ac_cv_env_F77_set=
ac_cv_env_F77_value=
ac_cv_env_FFLAGS_set=
ac_cv_env_FFLAGS_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=
ac_cv_env_host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_path_install='/usr/bin/install -c'
ac_cv_prog_AWK=awk
ac_cv_prog_ac_ct_CC=gcc
ac_cv_prog_make_make_set=yes
## ----------------- ##
## Output variables. ##
## ----------------- ##
ACLOCAL='${SHELL} /tmp/libevent-1.4.12-stable/missing --run aclocal-1.10'
AMDEPBACKSLASH=''
AMDEP_FALSE=''
AMDEP_TRUE=''
AMTAR='${SHELL} /tmp/libevent-1.4.12-stable/missing --run tar'
AR=''
AUTOCONF='${SHELL} /tmp/libevent-1.4.12-stable/missing --run autoconf'
AUTOHEADER='${SHELL} /tmp/libevent-1.4.12-stable/missing --run autoheader'
AUTOMAKE='${SHELL} /tmp/libevent-1.4.12-stable/missing --run automake-1.10'
AWK='awk'
BUILD_WIN32_FALSE=''
BUILD_WIN32_TRUE=''
CC='gcc'
CCDEPMODE=''
CFLAGS=''
CPP=''
CPPFLAGS=''
CXX=''
CXXCPP=''
CXXDEPMODE=''
CXXFLAGS=''
CYGPATH_W='echo'
DEFS=''
DEPDIR=''
DSYMUTIL=''
ECHO='/bin/echo'
ECHO_C='\c'
ECHO_N=''
ECHO_T=''
EGREP=''
EXEEXT=''
F77=''
FFLAGS=''
GREP=''
INSTALL_DATA='${INSTALL} -m 644'
INSTALL_PROGRAM='${INSTALL}'
INSTALL_SCRIPT='${INSTALL}'
INSTALL_STRIP_PROGRAM='$(install_sh) -c -s'
LDFLAGS=''
LIBOBJS=''
LIBS=''
LIBTOOL=''
LIBTOOL_DEPS=''
LN_S=''
LTLIBOBJS=''
MAKEINFO='${SHELL} /tmp/libevent-1.4.12-stable/missing --run makeinfo'
MKDIR_P='./install-sh -c -d'
NMEDIT=''
OBJEXT=''
PACKAGE='libevent'
PACKAGE_BUGREPORT=''
PACKAGE_NAME=''
PACKAGE_STRING=''
PACKAGE_TARNAME=''
PACKAGE_VERSION=''
PATH_SEPARATOR=':'
RANLIB=''
SED=''
SET_MAKE=''
SHELL='/bin/sh'
STRIP=''
VERSION='1.4.12-stable'
ac_ct_CC='gcc'
ac_ct_CXX=''
ac_ct_F77=''
am__fastdepCC_FALSE=''
am__fastdepCC_TRUE=''
am__fastdepCXX_FALSE=''
am__fastdepCXX_TRUE=''
am__include=''
am__isrc=''
am__leading_dot='.'
am__quote=''
am__tar='${AMTAR} chof - "$$tardir"'
am__untar='${AMTAR} xf -'
bindir='${exec_prefix}/bin'
build=''
build_alias=''
build_cpu=''
build_os=''
build_vendor=''
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE}'
dvidir='${docdir}'
exec_prefix='NONE'
host=''
host_alias=''
host_cpu=''
host_os=''
host_vendor=''
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
install_sh='$(SHELL) /tmp/libevent-1.4.12-stable/install-sh'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
mkdir_p='$(top_builddir)/./install-sh -c -d'
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='/usr/local'
program_transform_name='s,x,x,'
psdir='${docdir}'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target_alias=''
## ----------- ##
## confdefs.h. ##
## ----------- ##
#define PACKAGE_NAME ""
#define PACKAGE_TARNAME ""
#define PACKAGE_VERSION ""
#define PACKAGE_STRING ""
#define PACKAGE_BUGREPORT ""
#define PACKAGE "libevent"
#define VERSION "1.4.12-stable"
configure: exit 77
采纳答案by Ken Thomases
You have an old set of developer tools. gcc is reporting its version as 4.0.1. This may be left over from migrating from an older version of the OS. If you've installed Xcode 4.3.x, you need to launch it, go into its preferences, select the Downloads tab, and click "Install" next to the Command Line Tools package.
您有一套旧的开发人员工具。gcc 报告其版本为 4.0.1。这可能是从旧版本的操作系统迁移后遗留下来的。如果您已安装 Xcode 4.3.x,则需要启动它,进入其首选项,选择“下载”选项卡,然后单击“命令行工具”包旁边的“安装”。
回答by stereoscott
I have 10.8 installed and Xcode 4.4 with Command Line tools, and yet I was still getting this error. Rather than reinstall Xcode, I noticed there were two relevant lines in my config.log:
我安装了 10.8 和带有命令行工具的 Xcode 4.4,但我仍然收到此错误。我注意到我的 config.log 中有两行相关的行,而不是重新安装 Xcode:
configure:5130: checking for C compiler version
configure:5139: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc --version >&5
That path did not exist for me. Instead I had:
这条路对我来说并不存在。相反,我有:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
The C compiler ("cc") is located inside of that xctoolchain directory. I created a symlink for OSX10.8.xctoolchain to point to XcodeDefault.xctoolchain and that fixed it. Now the memcached installation script can find the compiler version and continue on its way.
C 编译器(“cc”)位于该 xctoolchain 目录中。我为 OSX10.8.xctoolchain 创建了一个符号链接以指向 XcodeDefault.xctoolchain 并修复了它。现在 memcached 安装脚本可以找到编译器版本并继续前进。
cd /Applications/Xcode.app/Contents/Developer/Toolchains
sudo ln -s XcodeDefault.xctoolchain OSX10.8.xctoolchain
As suggested in the comments, if you are having this problem on Yosemite (10.10) or Mavericks (10.9), you can update the symlink command above to point to that specific version (OSX10.9.xctoolchain
or OSX10.10.xctoolchain
).
正如评论中所建议的,如果您在 Yosemite (10.10) 或 Mavericks (10.9) 上遇到此问题,您可以更新上面的符号链接命令以指向该特定版本 (OSX10.9.xctoolchain
或OSX10.10.xctoolchain
)。
回答by konrad
When you see this error message, you might not have accepted the Xcode license agreementyet after an upgrade.
当您看到此错误消息时,您可能在升级后尚未接受Xcode 许可协议。
First of all, make sure you have upgraded your commandline tools:
首先,请确保您已升级命令行工具:
$ xcode-select --install
Now Apple wants you to agree to their license before you can use these tools:
现在,Apple 希望您在使用这些工具之前同意他们的许可:
$ gcc
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
$ sudo gcc
You have not agreed to the Xcode license agreements. You must agree to both license agreements below in order to use Xcode.
[...]
After you have accepted it, the commandline tools will work as expected.
接受后,命令行工具将按预期工作。
回答by Rimian
I had already installed the command line tools in xcode but I mine still errored out on:
我已经在 xcode 中安装了命令行工具,但我的仍然出错:
line 3619: /usr/bin/gcc-4.2: No such file or directory
When I entered which gcc
it returned
当我进入which gcc
它返回
/usr/bin/gcc
When I entered gcc -v
I got a bunch of stuff then
当我进入时,gcc -v
我得到了一堆东西
..
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
So I created a symlink:
所以我创建了一个符号链接:
cd /usr/bin
sudo ln -s gcc gcc-4.2
And it worked!
它奏效了!
(the config.log file is located in the directory that make is trying to build something in)
(config.log 文件位于 make 试图在其中构建内容的目录中)
回答by David Williams
I just had this issue building apache. The solution I used was the same as Mostafa, I had to export 2 variables:
我刚刚在构建 apache 时遇到了这个问题。我使用的解决方案与 Mostafa 相同,我必须导出 2 个变量:
export CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
CPP='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -E'
This was one Mac OSX Mavericks
这是一个 Mac OSX Mavericks
回答by Gurudath BN
First get the gcc path using
首先使用
Command: which gcc
Output: /usr/bin/gcc
命令:which gcc
输出:/usr/bin/gcc
I had the same issue, Please set the gcc path in below command and install
我有同样的问题,请在下面的命令中设置 gcc 路径并安装
CC=/usr/bin/gcc rvm install 1.9.3
CC=/usr/bin/gcc rvm install 1.9.3
Later if you get "Ruby was built without documentation" run below command
稍后,如果您得到“ Ruby was built without documentation”,请运行以下命令
rvm docs generate-ri
rvm docs generate-ri
回答by yndolok
Setting 'clang' as the compiler configure should use worked for me:
将 'clang' 设置为编译器配置应该对我有用:
export CC=clang
pip install --no-clean pycrypto
回答by homerjam
回答by jasonsemko
If anyone is coming here because RVM / Ruby is creating issues (Middleman/Grunt) I've solved my issue.
如果有人来这里是因为 RVM / Ruby 正在制造问题(中间人/咕噜声),我已经解决了我的问题。
PS. The answer by steroscott fixed my issue a while back...this time around not the case.
附注。steroscott 的答案不久前解决了我的问题……这一次并非如此。
In my case rvm is trying to use a downloaded gcc via homebrew. I ran a brew uninstall of gcc (gcc46 for me) and reran the code for the ruby installation (old project old ruby v)
就我而言,rvm 试图通过自制软件使用下载的 gcc。我运行了 gcc 的 brew 卸载(对我来说是 gcc46)并重新运行了 ruby 安装的代码(旧项目旧 ruby v)
$ brew uninstall gcc46
$ rvm install 1.9.3
during that process of checking for requirements it automatically fetched a newer gcc for me and boom, all is working now. Oh a big note, the gcc install from the rvm command can take around 10-15 minutes without throwing out any text, it's not frozen :) Good luck
在检查需求的过程中,它自动为我和繁荣获取了一个更新的 gcc,现在一切正常。哦,重要的是,从 rvm 命令安装 gcc 可能需要大约 10-15 分钟而不会抛出任何文本,它没有被冻结:) 祝你好运
回答by Florin Odagiu
I furiously read all of this page, hoping to find a solution for:
我疯狂地阅读了本页的所有内容,希望找到解决方案:
"configure: error: C compiler cannot create executables"
In the end nothing worked, because my problem was a "typing" one, and was related to CFLAGS. In my .bash_profile file I had:
最后没有任何效果,因为我的问题是“打字”问题,并且与 CFLAGS 有关。在我的 .bash_profile 文件中,我有:
export ARM_ARCH="arm64”
export CFLAGS="-arch ${ARM_ARCH}"
As you can observe --- export ARM_ARCH="arm64”--- the last quote sign is not the same with the first quote sign. The first one ( " ) is legal while the second one ( ” ) is not.
This happended because I made the mistake to use TextEdit (I'm working under MacOS), and this is apparently a feature called SmartQuotes: the quote sign CHANGES BY ITSELF TO THE ILLEGAL STYLE whenever you edit something just next to it.
Lesson learned: use a proper text editor...
如您所见 --- export ARM_ARCH= "arm64"--- 最后一个引号与第一个引号不同。第一个 ( " ) 是合法的,而第二个 ( ” ) 则不是。
发生这种情况是因为我错误地使用了 TextEdit(我在 MacOS 下工作),这显然是一个名为 SmartQuotes 的功能:每当您编辑旁边的内容时,引号都会自行更改为非法样式。
经验教训:使用合适的文本编辑器...