【问题标题】:Building log4cxx with APR使用 APR 构建 log4cxx
【发布时间】:2013-01-03 00:39:29
【问题描述】:

我需要在我不是 root 的 SuSE linux 系统上构建 log4cxx 库。包管理器 zypper 显然不知道 log4cxx。

我下载log4cxx和try to build with autotools

./configure

checking for APR... no
configure: error: APR could not be located. Please use the --with-apr option.

然后我搜索libapr

find / -name libapr*

/usr/share/doc/packages/libapr-util1
/usr/share/doc/packages/libapr1
/usr/lib64/libaprutil-1.so.0.3.12
/usr/lib64/libapr-1.so.0.4.5
/usr/lib64/libaprutil-1.so.0
/usr/lib64/libapr-1.so.0

所以我试试

./configure --with-apr=/usr/lib64/libapr-1.so.0

configure: error: the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file.

--with-apr=/usr/lib64/libapr-1.so.0.4.5--with-apr=/usr/lib64/ 也是如此。

./configure 查找哪个文件? --with-apr 期待什么?两个*.so.* 文件之一是所需的库吗?

【问题讨论】:

    标签: c++ shared-libraries autotools suse log4cxx


    【解决方案1】:

    您可能需要安装libapr1-devel 以便可以针对它进行编译。然后尝试重新运行./configure

    【讨论】:

    • ...还有libapr-util1-devel,然后./configure 工作,但make 失败并出现编译器错误。
    • 这是 make 的全部输出:gist.github.com/4577990 问题似乎是:inputstreamreader.cpp: In member function 'virtual log4cxx::LogString log4cxx::helpers::InputStreamReader::read(log4cxx::helpers::Pool&)': inputstreamreader.cpp:66:64: error: 'memmove' was not declared in this scope
    • 它试图重新运行自动工具的事实让我感到困扰(但可能与您的问题无关)。使用 make distcheck 正确制作的 tarball 不需要重新运行 autotools,因为它们是开发人员工具。
    • 至于实际的编译错误:memmove 应该由该文件中的 #include <cstring> 行提供,并且它已在 svn 中修复超过 4 年 svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/… ,所以我不确定是什么继续。
    【解决方案2】:

    我遇到了同样的问题,我认为您使用的是 appache 网站上的源代码,我认为该源代码已过时。几年前,这个问题已经在 SVN 主干中修复了(哈哈,我猜就在这个问题被问到的时候)。

    只需拉取svn trunk的源码并编译即可:

    svn checkout http://svn.apache.org/repos/asf/incubator/log4cxx/trunk apache-log4cxx 
    ./autogen.sh
    ./configure
    make
    make check
    sudo make install
    

    【讨论】:

    • 最近的 git 仓库 git clone http://git-wip-us.apache.org/repos/asf/logging-log4cxx.git 也修复了它。感谢您的提示。
    【解决方案3】:

    software.opensuse.org 有人在liblog4cxx10 上为最新版本的 openSUSE 和 SLE 构建了软件包。也许这对您有用,而不是自己构建。

    【讨论】:

    • @EliahKagan RPM 包只是一个 cpio 存档。即使 OP 无法安装软件包,他们也可以将其解包到他们可以写入的地方并修复环境,这样它就可以工作了。它显然不如安装它好。如果他们没有任何依赖项(显然像 libapr1),那么如果它们还没有安装,他们也必须解包这些依赖项。但是让具有root访问权限的人安装它们会更容易。至少他们不会以这种方式安装构建依赖项(如 libapr1-devel)。
    • 无论如何,OP 都必须安装任何缺少的运行时依赖项,并为其编译的 liblog4cxx 修复环境。
    【解决方案4】:

    迈克尔戈伦是对的。 缺少多个“.h”文件。 所以你必须在启动 make 之前添加它们。

    sed -i '1i#include <string.h>\n'    src/main/cpp/inputstreamreader.cpp
    sed -i '1i#include <string.h>\n'    src/main/cpp/socketoutputstream.cpp   
    sed -i '1i#include <string.h>\n'    src/examples/cpp/console.cpp       
    sed -i '1i#include <stdio.h>\n'     src/examples/cpp/console.cpp       
    

    【讨论】:

      【解决方案5】:

      我在 3.3.4-5.fc17.x86_64 上遇到了同样的问题,并通过将适当的 H 文件包含到 make 实用程序报告的 CPP 文件中来解决它。 在我的情况下,每次遇到新错误时,我应该运行 make 实用程序 3 次,并通过将适当的 include H 添加到报告的 CPP 文件来修复它。

      主要思想如下: 1)通过运行 man 实用程序进行检查,其中定义了错误中提到的函数。 例如, man memmove 说它是在 string.h 头文件中定义的。 2) 将适当的包含文件添加到 CPP 文件中。 例如,make 实用程序抱怨 inputstreamreader.cpp 没有找到 memmove 函数。打开 inputstreamreader.cpp 文件并将 string.h 添加到其头文件中。 3) 运行 make 实用程序,直到 log4cxx 编译无错误。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-07-04
        • 2012-09-18
        • 1970-01-01
        • 1970-01-01
        • 2017-08-30
        • 2012-08-22
        • 1970-01-01
        相关资源
        最近更新 更多