我有以下无法编译的代码。
#include <stdio.h>
#include <log4cpp/Category.hh>
#include <log4cpp/FileAppender.hh>
#include <log4cpp/SimpleLayout.hh>
#define LOGFILE "./test.log"
int main()
{
/*Setting up Appender, layout and Category*/
log4cpp::Appender *appender = new log4cpp::FileAppender("FileAppender",LOGFILE);
log4cpp::Layout *layout = new log4cpp::SimpleLayout();
log4cpp::Category& category = log4cpp::Category::getInstance("Category");
appender->setLayout(layout);
category.setAppender(appender);
category.setPriority(log4cpp::Priority::INFO);
/*The actual logging*/
category.info("This is for tracing the flow");
category.notice("This is to notify certain events");
category.warn("This is to generate certain warnings");
}
$ g++ -I/usr/local/include/log4cpp -L/usr/local/lib/ -llog4cpp -lpthread log.cc
这编译。但后来我收到以下错误。
./a.out: error while loading shared libraries: liblog4cpp.so.4: cannot open shared object file: No such file or directory
我确实liblog4cpp.so.4
在 /usr/local/lib 文件夹中看到了。我该如何解决这个问题?