程序编译精细与boost libs,但运行时错误 [英] Program compiles fine with boost libs, but error when running it
问题描述
简而言之...
C ++程序(使用boost库)在Eclipse中编译良好,但随后加载共享库时出错:libboost_thread.so。
详细信息 / h1>
我正在C ++上运行一个基本程序,以检查是否可以正确使用boost线程库。
#include< boost / thread / thread.hpp>
#include< iostream>
void hello()
{
Std :: cout<<Hello,I am a thread<< std :: endl;
}
int main()
{
boost :: thread th1(& hello);
th1.join();
}
代码编译正常,所以我相信我已经安装并设置了但是当我尝试运行程序时,我在控制台中得到以下错误消息
错误加载共享库时:libboost_thread.so.1.46.1:无法打开共享对象文件:无此类文件或目录
解决方案我有一个非常类似的问题FreeFileSYnc,编译良好,但不会启动由于libboost线程错误:
FreeFileSync:加载共享库时出错:libboost_thread.so.1.51.0:无法打开共享对象文件:否这样的文件或目录
为了修复它,我做了:
sudo ldconfig / usr / local / lib
它可能会帮助其他人。
In a nutshell...
C++ program (using the boost libraries) compiles fine in Eclipse, but then "error while loading shared libraries: libboost_thread.so.1.46.1: cannot open shared object file: No such file or directory" it shown when running it.
Details
I am running a basic program on C++ to check that I can use the boost threading libraries correctly.
#include <boost/thread/thread.hpp> #include <iostream> void hello () { Std::cout<<"Hello, I am a thread"<<std::endl; } int main () { boost::thread th1(&hello); th1.join(); }
The code compiles fine, so I believed that I had installed and set up the boost libraries correctly (added directories to include etc)
However when I try to run the program I get the following error message in the consol
error while loading shared libraries: libboost_thread.so.1.46.1: cannot open shared object file: No such file or directory
解决方案I had a very similar issue with FreeFileSYnc, compiles fine but won't launch due to a libboost thread error :
FreeFileSync: error while loading shared libraries: libboost_thread.so.1.51.0: cannot open shared object file: No such file or directory
To fix it I did :
sudo ldconfig /usr/local/lib
It may help other people.
这篇关于程序编译精细与boost libs,但运行时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!