centos6.8 编译安装 log4cxx

默认分类5年前 (2020)发布 fdadmin
7,295 0 0

最近碰到一个这样的错误,说是找不到liblog4cxx.so

error while loading shared libraries: liblog4cxx.so.10: cannot open shared object file: No such file or directory

于是找了下解决方案。

首先下载
====================================================================================================

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’在此作用域中尚未声明

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

© 版权声明

相关文章

暂无评论

暂无评论...