util_pcre.c:104: 编译 Apache HTTPD 2.4.17 时未定义对“pcre_free”的引用。collect2:错误:ld 返回 1 退出状态

util_pcre.c:104: 编译 Apache HTTPD 2.4.17 时未定义对“pcre_free”的引用。collect2:错误:ld 返回 1 退出状态

在新的 EC2 上,我在编译 httpd 时遇到一类问题。似乎 Apache 的代码无法从库中找到函数/函数定义。

我在全新 RHEL 上安装 httpd 所采取的步骤。

    sudo yum install gcc
    extracted apr's and apr's source in respective directories under srclib of httpd source code
    compiled latest pcre
    sudo yum install pcre-devel (because of error cannot find pcre.h while ./configure)
    ./configure --with-included-apr --prefix='/server/httpd/httpd-2.4.17' --with-pcre='/usr/local/bin/pcre-config' --with-ssl='/usr/bin/openssl'
    make

在 make install 步骤中,一切运行良好,但随后弹出以下错误。我认为所有错误都是相互关联的。

    /server/httpd/httpd-2.4.17-source/server/util_pcre.c:104: undefined reference to `pcre_free'
    server/.libs/libmain.a(util_pcre.o): In function `ap_regcomp':
    /server/httpd/httpd-2.4.17-source/server/util_pcre.c:138: undefined reference to `pcre_compile2'
    /server/httpd/httpd-2.4.17-source/server/util_pcre.c:151: undefined reference to `pcre_fullinfo'
    server/.libs/libmain.a(util_pcre.o): In function `ap_regexec_len':
    /server/httpd/httpd-2.4.17-source/server/util_pcre.c:207: undefined reference to `pcre_exec'
    server/.libs/libmain.a(util_pcre.o): In function `ap_regname':
    /server/httpd/httpd-2.4.17-source/server/util_pcre.c:269: undefined reference to `pcre_fullinfo'
    /server/httpd/httpd-2.4.17-source/server/util_pcre.c:271: undefined reference to `pcre_fullinfo'
    /server/httpd/httpd-2.4.17-source/server/util_pcre.c:273: undefined reference to `pcre_fullinfo'

经过一番谷歌搜索后,我发现如果我可以纠正 Makefile 中调用 gcc 的方式,就可以解决这个问题,但我甚至无法在 Makefile 中找到术语“gcc”。

请帮忙。

更新

我也可以在我的本地 Ubuntu 机器上用同样的步骤轻松重现这一点。对于 ubuntu 安装libpcre3-dev代替pcre-devel

答案1

在这个问题上浪费了 20 多个小时后,我找到了解决方案。

最新的 pcre 版本是pcre2-10.10 当我重新安装(从源代码编译)旧版本的 pcre 时pcre-8.38,编译顺利,没有任何错误。

    make clean (because wrong tries with ./configure messes up the Makefile)
    ./configure <options>
    make 
    make install

相关内容