【问题标题】:Problems with compiling apache2 on Mac OS X Mountain Lion在 Mac OS X Mountain Lion 上编译 apache2 的问题
【发布时间】:2012-11-27 15:00:35
【问题描述】:

在我的 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 个小时里一直在努力解决它。 请帮忙。提前致谢。

【问题讨论】:

  • 是的,我做到了,但那里没有任何东西可以帮助我。
  • 那么也许它可以帮助我们帮助您?请编辑您的问题以包含日志文件的最后几行。
  • 我按照您的要求添加了日志文件的最后几行,请看一下并告诉我您的想法

标签: macos apache


【解决方案1】:

我只是在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

你至少应该进入下一步。

【讨论】:

  • 非常感谢阿德里安,你刚刚救了我的命 :)
  • 非常感谢阿德里安你救了我的命 :)
  • 看起来 APR-Util / APR(基于共享库编译不同产品的便携式环境)在 Mountain Lion 中被破坏了。它链接到错误的编译器。有人知道如何切换这些吗?例如对于 apxs,您可以运行 apxs -c -S cc=/usr/bin/gcc 等
  • 可能需要用 OSX10.9 for Maverick 替换 OSX10.8
  • 在环境设置的黑暗森林中,我发现了您的救命之光 :) 谢谢。
【解决方案2】:

对于OSX 10.9 Mavericks Apache已经安装好了,可以直接到终端输入以下命令

查找 Apache 版本

httpd -v

开始:

sudo apachectl start 

停止:

sudo apachectl stop

重启:

sudo apachectl restart

【讨论】:

    【解决方案3】:

    我在 OSX Mavericks 上尝试编译 Apache 2.2.24 并遇到此错误。我从其他答案中看到问题出在 apxr 上,因此 APR 为 gcc 返回了错误的位置。 Apple 提供了这个,而 Apache 配置使用的是 Apple 提供的。

    一时兴起,我查看并看到配置脚本有一个选项可以忽略系统提供的 APR 并使用它自己的。

    所以我这样做了:

    ./configure --with-included-apr
    

    并且它通过了配置步骤并且没有错误地编译。

    【讨论】:

    • 为此,您需要下载 apache apr 库。例如。像这样cd srclib/; curl http://wwwftp.ciril.fr/pub/apache//apr/apr-1.5.1.tar.gz | tar xvz; curl http://wwwftp.ciril.fr/pub/apache//apr/apr-util-1.5.4.tar.gz | tar xvz; mv apr-1.5.1 apr; mv apr-util-1.5.4 apr-util; cd apr; configure; make; cd .. ; cd apr-util; configure; make; cd .. ; cd ..
    【解决方案4】:
    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

    【讨论】:

    • 这是对这个问题(或)不同问题的答案以及您解决它的方式吗?如果是后者,请将其作为不同的问题发布并添加您自己的答案。
    【解决方案5】:

    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。相反,他们告诉您查看Optional features 下的./configure --help 的输出,其中列出了--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 正在运行,我在浏览器中输入了以下 url:

    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']);
    
    ?>
    

    ============

    在收到与操作相同的错误消息后,我在httpd-2.4.18 目录中检查了config.log,其中一行显示:

    ./configure: line 5326: /Applications/Xcode.app/Contents/Developer/Toolchains/
    OSX10.10.xctoolchain/usr/bin/cc: 
    No such file or directory
    

    所以配置脚本正在寻找:

    1. 一个名为:

      的目录

      /Applications/Xcode.app/Contents/Developer/ Toolchains/OSX10.10.xctoolchain/usr/bin/

    2. 该目录中有一个名为 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的目录。因此,配置脚本无法在用于查找cc 文件的路径中找到目录OSX10.10.xctoolchain。为什么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 的 clang 编译器的链接。

    接受的答案会创建一个从名称 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.xctoolchainOSX10.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
    
    1. 在我的系统上,第一个目录不包含 cc 文件,因此我没有理由将该目录添加到我的 PATH 中。

    2. 第二个目录是configure说找不到的目录。将不存在的目录添加到 PATH 仍然意味着它不存在。

    3. 在任何情况下,配置脚本似乎都没有在 PATH 目录中搜索 cc,因为错误消息将不存在的路径列为问题。搜索 PATH 目录会如何导致错误消息列出不存在的路径?配置脚本似乎从其他地方获取指示,告诉它在哪里搜索cc

    4. 我不知道为什么@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
    

    现在错误消息中的所有路径都是正确的,但是有些“未通过健全性检查”。我放弃!也许其他人可以从我离开的地方继续。

    好的,感谢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 结合使用。这就是我要进入那个兔子洞的地方。

    【讨论】:

      【解决方案6】:

      在 Mac OS X 10.9 (Mavericks) 上遇到同样的问题;是的,正如 user3097424 所说,Apache 是为 Mavericks 用户预装的,但对我来说是 2.2 版。因此,需要升级到 2.4,按照 Adrian Rodriguez 的说法,创建一个符号链接,将 '10.8' 替换为 '10.9':

      sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain

      【讨论】:

        【解决方案7】:

        您可以将路径添加到库路径,而不是创建符号链接,只需将适当的目录用于您的 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
        ...
        

        我认为这种方法更简洁一些,无需像不同工具所期望的那样在不同的地方添加符号链接。

        无论如何,这只是一个替代解决方案。

        希望这会有所帮助。

        【讨论】:

        • OSX Yosemite(10.10.5) : 在得到与操作相同的错误后,我在httpd-2.4.18 目录中检查了config.log,它说:./configure: line 5326: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc: No such file or directory。我不确定将不存在的目录添加到我的 PATH 将如何帮助配置脚本找到 cc 文件。
        【解决方案8】:

        @AlphaZygma 这对我很有用。我在 10.8.5 上,必须将以下内容添加到 /etc/paths

        /Applications/Xcode.app/Contents/Developer/usr/bin
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
        

        而不是你的。

        【讨论】:

        • OSX Yosemite(10.10.5):第二个目录对我来说是存在的,但我不确定如何使 configure 在该目录而不是不存在的目录中查找 cc/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/b‌​in/ which config .log 说是我的错误的原因。
        【解决方案9】:

        让我通过的完整解决方案:

        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
        

        【讨论】:

        • 这与接受的答案基本相同。事实证明,cc 也位于 /usr/bin 以及 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ 中。这个答案只是将名称/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc 符号链接到/usr/bin/cc 而不是现有的/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
        【解决方案10】:

        我最近刚刚更新到 Mavericks 并且正在重新创建我的 Web 开发环境(包括安装端口)。我在升级端口时遇到了这个问题:

        checking whether the C compiler works... no
        

        我以为我已经完成了所有设置,包括从 App Store 安装 XCode。但是一直有问题。我能够通过实际运行一次 XCode、接受许可协议并让 XCode 完全启动来修复它。下次我尝试升级端口时,我没有收到上述错误。

        【讨论】:

          猜你喜欢
          • 2012-09-15
          • 2012-08-02
          • 2013-02-12
          • 1970-01-01
          • 1970-01-01
          • 2012-01-23
          • 2012-11-15
          • 2013-09-24
          • 1970-01-01
          相关资源
          最近更新 更多