在我的Mac(10.8)上尝试编译最新版本的apache web服务器(2.4.3)时遇到了问题。当我运行./configure命令时,我得到以下输出:
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-apple-darwin12.0.0
checking host system type... x86_64-apple-darwin12.0.0
checking target system type... x86_64-apple-darwin12.0.0
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... yes
setting CC to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc"
setting CPP to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -E"
setting CFLAGS to " "
setting CPPFLAGS to " -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK"
setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... yes
checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc
checking whether the C compiler works... no
configure: error: in `/Users/cti/Downloads/Applications/httpd-2.4.3':
configure: error: C compiler cannot create executables
See `config.log' for more details
以下是日志文件中的最后几行:
## ----------- ##
## Core tests. ##
## ----------- ##
configure:3056: checking for chosen layout
configure:3058: result: Apache
configure:3861: checking for working mkdir -p
configure:3877: result: yes
configure:3886: checking for grep that handles long lines and -e
configure:3944: result: /usr/bin/grep
configure:3949: checking for egrep
configure:4011: result: /usr/bin/grep -E
configure:4027: checking build system type
configure:4041: result: x86_64-apple-darwin12.0.0
configure:4061: checking host system type
configure:4074: result: x86_64-apple-darwin12.0.0
configure:4094: checking target system type
configure:4107: result: x86_64-apple-darwin12.0.0
configure:4137:
configure:4139: Configuring Apache Portable Runtime library...
configure:4141:
configure:4182: checking for APR
configure:4327: result: yes
configure:4587:
configure:4589: Configuring Apache Portable Runtime Utility library...
configure:4591:
configure:4628: checking for APR-util
configure:4707: result: yes
configure:4968: checking for gcc
configure:4995: result: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc
configure:5224: checking for C compiler version
configure:5233: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc --version >&5
./configure: line 5235: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc: No such file or directory
configure:5244: $? = 127
configure:5233: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -v >&5
./configure: line 5235: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc: No such file or directory
configure:5244: $? = 127
configure:5233: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -V >&5
./configure: line 5235: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc: No such file or directory
configure:5244: $? = 127
configure:5233: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -qversion >&5
./configure: line 5235: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc: No such file or directory
configure:5244: $? = 127
configure:5264: checking whether the C compiler works
configure:5286: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK conftest.c >&5
./configure: line 5288: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc: No such file or directory
configure:5290: $? = 127
configure:5328: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:5333: error: in `/Users/cti/Downloads/Applications/httpd-2.4.3':
configure:5335: error: C compiler cannot create executables
See `config.log' for more details
正如您在日志输出中看到的那样,./configure中的脚本找不到我的C编译器的路径,因为它位于/Applications/Xcode.app/Contents/Developer/usr/bin/cc
而不是/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc
,因为它在日志输出中说明
您可能会说解决方案很简单,我所要做的就是修改配置脚本,对吧?好吧,问题在于我对shell脚本一无所知,这也是我在过去3个小时里一直在努力的原因。
请帮忙。提前谢谢。
答案 0 :(得分:53)
我只是在this post I created and answered中遇到类似的问题,所以我想我会分享我的发现。只需创建符号链接:
# Create a symlink to default Xcode toolchain for OS X lion
sudo ln -s \
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain \
/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain
# Create a symlink to default Xcode toolchain for OS X maverick
sudo ln -s \
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain \
/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain
你应该至少进入下一步。
答案 1 :(得分:11)
对于OSX 10.9 Mavericks已安装Apache,您可以直接转到终端并输入以下命令
查找Apache版本
httpd -v
开始:
sudo apachectl start
停止:
sudo apachectl stop
要重新启动:
sudo apachectl restart
答案 2 :(得分:9)
我在OSX Mavericks上并试图编译Apache 2.2.24并遇到此错误。我从其他答案中看到问题出在apxr上,因此APR返回错误的gcc位置。 Apple提供此服务,Apache配置使用Apple提供的配置。
我突然想到,看到配置脚本有一个选项可以忽略系统提供的APR并使用它自己的。
所以我这样做了:
./configure --with-included-apr
它已经过了配置步骤并且编译没有错误。
答案 3 :(得分:2)
checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc accepts -g... yes
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc option to accept ISO C89... none needed
checking how to run the C preprocessor... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -E
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc option to accept ISO C99... none needed
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
====
我已经下载了pcre-config,运行:./configure;make;make install
现在...... Tcharammmm! Httpd apache完全安装:D
答案 4 :(得分:2)
OSX Yosemite (10.10.5)
:
接受的答案对我有用:
$ cd /Applications/Xcode.app/Contents/Developer/Toolchains
$ ln -s XcodeDefault.xctoolchain/ OSX10.10.xctoolchain
^ ^
| |
existing dir(or file) link name
(以下解释为何起作用。)
然后:
httpd-2.4.18$ ./configure (php may require an additional option)
如果你还要安装php ,你可能需要为./configure添加另一个选项。
installing php on Unix的基本说明还提供了有关如何安装apache的说明:
./configure --enable-so
make
make install
Apache的配置帮助说明了这一点:
httpd-2.4.18$ ./configure --help
...
...
--enable-so DSO capability. This module will be automatically
enabled unless you build all modules statically.
这似乎表明--enable-so
选项可能是默认选项,但apache安装说明甚至没有提到--enable-so
。在configure的apache 2.2 文档中,我发现了这一点:
Modules, disabled by default
Some modules are compiled by default and have to be enabled explicitly...
...
...
--enable-so
...
configure的apache 2.4 文档没有提及--enable-so。相反,他们会告诉您查看./configure --help
下Optional features
下的输出,其中列出了--enable-so。
因此,我认为您应该像这样配置apache:
httpd-2.4.18$ ./configure --enable-so
======
安装PHP
为了让mysql与php一起工作,我不得不重新安装php并在php安装文档中更改以下行:
php-7.0.2$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
为:
php-7.0.2$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-pdo-mysql
使用第一个,配置输出表示--with-mysql
选项不存在 - 否则php安装正常,并且apache的htdocs directory
中的php文件由php执行。
问题是php已经改变了它的mysql支持,并且mysql_connect()
已被弃用(并从php7中删除),所以现在需要pdo-mysql adapter
,如php docs中所述。
重新安装php之后,make install
的最后几行说了这个:
You may want to add: /usr/local/lib/php to your php.ini include_path
php.ini
位于此处:/usr/local/lib/php.ini
,我进行了更改:
include_path = ".:/php/includes:/usr/local/lib/php"
然后我重新启动了apache,确保mysql正在运行,我在浏览器中输入了以下网址:
http://localhost:8080/mysql_test.php
我的测试PDO脚本工作(位于/ usr / local / apache2 / htdocs目录中):
<?php
$user = 'root';
$password = ’root_password_here’;
$host = 'localhost';
$dbname = 'my_db';
$pdo = new PDO(
"mysql:host=$host; dbname=$dbname",
$user,
$password
);
$statement = $pdo->query("SELECT 'Hello, dear MySQL user!' AS _message FROM DUAL");
$row = $statement->fetch(PDO::FETCH_ASSOC);
echo htmlentities($row['_message']);
?>
===========
收到与操作相同的错误消息后,我检查了config.log
目录中的httpd-2.4.18
,其中的一行显示:
./configure: line 5326: /Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.10.xctoolchain/usr/bin/cc:
No such file or directory
所以configure脚本正在寻找:
名为:
的目录 /Applications/Xcode.app/Contents/Developer/
Toolchains/OSX10.10.xctoolchain/usr/bin/
该目录中名为cc
的文件。
好的,让我们看看cc
是否在该目录中:
~$ cd/Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.10.xctoolchain/usr/bin/
-bash: cd: /Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.10.xctoolchain/usr/bin/: No such file or directory
这意味着该目录不存在。现在你必须弄清楚那个长路径中哪个目录不存在:
~$ cd /Applications/Xcode.app
/Applications/Xcode.app$ cd Contents/Developer
/Applications/Xcode.app/Contents/Developer$ cd Toolchains/OSX10.10.xctoolchain
-bash: cd: Toolchains/OSX10.10.xctoolchain/: No such file or directory
/Applications/Xcode.app/Contents/Developer$ cd Toolchains
/Applications/Xcode.app/Contents/Developer/Toolchains$ ls
XcodeDefault.xctoolchain
您可以看到没有名为OSX10.10.xctoolchain
的目录 - 只有一个名为XcodeDefault.xctoolchain
的目录。因此,配置脚本无法在用于查找OSX10.10.xctoolchain
文件的路径中找到目录cc
。为什么configure
正在寻找该目录?因为编写脚本的开发人员搞砸了或者Apple搞砸了。
configure
的真正目标不是找到目录,而是找到讨厌的cc
文件。事实证明cc
文件位于此处:
/Applications/Xcode.app/Contents/Developer/Toolchains/
XcodeDefault.xctoolchain/usr/bin$ ls
...
cc
clang
...
...
更为好奇:
/Applications/Xcode.app/Contents/Developer/
Toolchains/XcodeDefault.xctoolchain/usr/bin$ ls -al cc
lrwxr-xr-x 1 7stud admin 5 Oct 29 15:22 cc -> clang
cc
只是Xcode铿锵编译器的链接。
接受的答案会创建一个从名称OSX10.10.xctoolchain
到实际包含cc
文件的目录的链接(尽管有几个目录更深)XcodeDefault.xctoolchain
:
Applications/
Xcode.app/
Contents/
Developer/
Toolchains/
XcodeDefault.xctoolchain/
OSX10.10.xctoolchain/ -> XcodeDefault.xctoolchain/
usr/
bin/
cc
换句话说,在创建链接后,有两条路径:
/Applications/Xcode.app/Contents/Developer/Toolchains/
XcodeDefault.xctoolchain/usr/bin
/Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.10.xctoolchain/usr/bin
将是等效的。名称XcodeDefault.xctoolchain
和OSX10.10.xctoolchain
将是同一目录的别名。
====
我不明白@AlphaZygma's answer
。它建议将以下两个目录添加到PATH(通过/ etc / paths):
/Applications/Xcode.app/Contents/Developer/usr/bin
/Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.8.xctoolchain/usr/bin
在我的系统上,第一个目录不包含cc
文件,所以我没有理由将该目录添加到我的PATH中。
第二个目录是配置的目录,说它无法找到。将不存在的目录添加到PATH仍然意味着它不存在。
在任何情况下,配置脚本似乎都没有在cc
的PATH目录中搜索,因为错误消息将不存在的路径列为问题。如何搜索PATH目录会导致列出不存在的路径的错误消息?配置脚本似乎是从其他地方获取路线,告诉它在哪里搜索cc
。
我不确定为什么@AlphaZygma会在/etc/paths
中的某些现有路径之间插入新路径。为什么不在现有路径下添加新路径?
我尝试了几个不同版本的答案,但没有任何对我有用。
====
我查看了./configure --help
的输出:
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
...
...
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
嘿,CC列在那里。试试吧:
$ ./configure CC=/Applications/Xcode.app/Contents/Developer/
Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
...
...
checking for APR... yes
setting CPP to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc -E"
setting CFLAGS to " "
setting CPPFLAGS to " -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -DDARWIN_10"
setting LDFLAGS to " "
configure:
...
...
configure: error: C compiler cannot create executables
更仔细地看一下这一行:
setting CPP to "/Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.10.xctoolchain
配置脚本仍然提到与CPP一起存在的不存在的路径。再次查看./configure --help
的输出:
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
...
...
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
最后一行列出了错误行中提到的变量CPP。试试吧:
$ ./configure \
> CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc \
> CPP=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
...
...
checking how to run the C preprocessor... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
configure: error: in `/Users/7stud/Downloads/httpd-2.4.18':
configure: error: C preprocessor "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc" fails sanity check
See `config.log' for more details
现在错误消息中的所有路径都是正确的,但是&#34;无法进行完整性检查&#34;。我放弃!也许其他人可以从我离开的地方继续。
好的,感谢建议here,以下工作:
$ ./configure \
> 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'
可以缩短为:
$ ./configure \
> CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc \
> CPP='cc -E'
但是make
失败了:
$ make
...
/usr/share/apr-1/build-1/libtool: line 8962: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc: No such file or directory
再次提到了不存在的路径 - 这次与libtool
一起提到。就我在那个兔子洞里走下去而言。
答案 5 :(得分:1)
在Mac OS X 10.9(Mavericks)上遇到同样的问题;是的,因为user3097424声明,Apache已预先安装给Mavericks用户,不过对我来说,版本2.2。因此,需要升级到2.4,就像Adrian Rodriguez所说并创建一个符号链接,取代&#39; 10.8&#39;用&#39; 10.9&#39;:
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain
答案 6 :(得分:0)
您可以只添加路径到库路径,而不是创建符号链接,只需使用适当的OSX版本目录。
因此,在您的情况下,它可能看起来像
[user@host ~]$ sudo vi /etc/paths
/usr/bin
/Applications/Xcode.app/Contents/Developer/usr/bin
/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin
/bin
...
我认为这种方法更加清晰,无需像不同工具所期望的那样在不同的地方添加符号链接。
无论如何,这只是一个替代解决方案。
希望这有帮助。
答案 7 :(得分:0)
@AlphaZygma这对我很有用。我在10.8.5并且必须将以下内容添加到/etc/paths
:
/Applications/Xcode.app/Contents/Developer/usr/bin
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
而不是你的。
答案 8 :(得分:0)
允许我通过的完整解决方案:
checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc
checking whether the C compiler works... no
问题可以在这里找到: http://mac-dev-env.patrickbougie.com/apache/
命令是(有些需要sudo su):
cd /usr/local/src (mkdir /usr/local/srt if /usr/local/src doesnt exist)
curl --remote-name http://mirror.csclub.uwaterloo.ca/apache/httpd/httpd-2.4.9.tar.gz
tar -xzvf httpd-2.4.9.tar.gz
rmhttpd-2.4.9.tar.gz
cd httpd-2.4.9
sudo xcode-select -switch /
mkdir -p /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin (this might require sudo su)
ln -s /usr/bin/cc /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc (this might require sudo su)
./configure --prefix=/usr/local/apache-2.4.9
make
make install
ln -s apache-2.4.9 /usr/local/apache
答案 9 :(得分:0)
我刚刚更新到Mavericks并重新创建了我的Web开发环境(包括安装端口)。我在升级端口时遇到了这个问题:
checking whether the C compiler works... no
我认为我已经完成了所有设置,包括从App Store安装XCode。但一直有问题。我能够通过实际运行XCode一次,接受许可协议,并让XCode完全启动来修复它。下次我尝试升级端口时,我没有收到上面的错误。