1 参照《编译log4cplus-2.0.x备忘录》博文中“linux下 编译log4plus共享库”部分的说明编译出
log4cplus.so。
2: 经过上面的第一步后log4cplus.so默认安装在/usr/local/lib目录下
3:在终端执行如下命令,将/usr/local/lib加入共享库搜索目录中:
sudo vim /etc/profile
将export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib 加入到最后,保存该文件即可
4:重启linux
5:在终端执行 export $ LD_LIBRARY_PATH ,之后看执行结果中是否包含了 /usr/local/lib,如果没
有,证明第三步没有执行成功,或者部分Linux系统设置LD_LIBRAAY_PATH变量,并不能生
效,此时需要将变量写入/etc/ld.so.conf
,如下所示:
inlcude /usr/local/lib
然后执行如下命令即可立即生效:
sudo ldconfig /etc/ld.so.conf
6: 在步骤1中生成了log4cplus.so、log4cplusU.so两个版本,后者是unicode版,适用windows下。
请注意:Linux下,必须用log4cplus.so而不能用log4cplusU.so,否则链接时会报:
undefined reference to xxxxxxx 类似的错误。
注意:网上的说按下面那样都不能解决问题:
./configure CXXFLAGS="-std=c++0x"