使用APR构建log4cxx

Building log4cxx with APR

本文关键字:log4cxx 构建 APR 使用      更新时间:2023-10-16

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

我下载了log4cxx并尝试使用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.*文件中的一个是所需的库吗?

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

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

直接拉出svn主干的源代码并编译它:

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

在software.opensuse.org上,有人在liblog4cxx10上为最新版本的openSUSE和SLE构建了包。也许这更适合你,而不是自己构建。

MichaelGoren是对的。有多个"。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       

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

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