centos6.8 编译安装 log4cxx(liblog4cxx.so.10)

本文详细介绍了如何从源代码编译安装Apache APR、APR-Util及Log4cxx库,包括下载源码、配置编译参数、解决常见编译错误等步骤,为开发者提供了实用的参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


首先下载
====================================================================================================
wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
wget http://mirrors.cnnic.cn/apache/logging/log4cxx/0.10.0/apache-log4cxx-0.10.0.tar.gz

编译安装

====================================================================================================
mkdir ~/libs

tar  zxvf apr-1.5.2.tar.gz

cd apr-1.5.2

./configure --prefix=${HOME}/libs && make && make install
-----------------------------------------------------------------------------------------

cd ..

tar  zxvf apr-util-1.5.4.tar.gz

cd apr-util-1.5.4

./configure --prefix=${HOME}/libs --with-apr=${HOME}/libs && make && make install
------------------------------------------------------------------------------------------------

cd ..

tar  xzvf apache-log4cxx-0.10.0.tar.gz

cd apache-log4cxx-0.10.0

./configure --with-charset=utf-8  --with-apr=${HOME}/libs  --with-apr-util=${HOME}/libs && make && make install

 

====================================================================================================
报错往下看:
进行以下操作:

1.vim src/main/cpp/inputstreamreader.cpp
增加#include <string.h>;
#include <log4cxx/logstring.h>
#include <log4cxx/helpers/inputstreamreader.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/pool.h>
#include <log4cxx/helpers/bytebuffer.h>
+
#include <string.h>
+
否则会出现inputstreamreader.cpp:66: error: 'memmove' was not declared in this scope
make[3]: *** [inputstreamreader.lo] 错误 1


2.vim src/main/cpp/socketoutputstream.cpp
增加#include <string.h>;
#include <log4cxx/logstring.h>
#include <log4cxx/helpers/socketoutputstream.h>
#include <log4cxx/helpers/socket.h>
#include <log4cxx/helpers/bytebuffer.h>
+
#include <string.h>
+
否则会出现socketoutputstream.cpp:52: error: 'memcpy' was not declared in this scope

 

3.vim src/examples/cpp/console.cpp
增加#include <string.h>,#include <stdio.h>;
+
#include <stdio.h>
+
#include <stdlib.h>
+
#include <string.h>
+
#include <log4cxx/logger.h>
#include <log4cxx/consoleappender.h>
#include <log4cxx/simplelayout.h>
#include <log4cxx/logmanager.h>
#include <iostream>
#include <locale.h>
否则会出现
console.cpp: In function ‘int main(int, char**)’:
console.cpp:58: 错误:‘puts’在此作用域中尚未声明

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值