C++ /usr/bin/ld: 找不到 -lboost_system-mt
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4596492/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
/usr/bin/ld: cannot find -lboost_system-mt
提问by skyeagle
I recently upgraded from boost 1.40 to 1.45 by removing the previous boost directory completely, downloading the 1.45 sources and rebuilding the libraries I wanted. I then installed the libs using bjam install.
我最近从 boost 1.40 升级到 1.45,方法是完全删除以前的 boost 目录,下载 1.45 源代码并重建我想要的库。然后我使用 bjam install 安装了库。
Nothing else has changed on my machine, yet, now when I am building my C++ program, I get the following link error:
我的机器上没有其他任何变化,但是,现在当我构建我的 C++ 程序时,我收到以下链接错误:
/usr/bin/ld: cannot find -lboost_system-mt
I searched and the file really does not exist. It seems that the mt libraries are no longer part of the library - or am I missing something?
我搜索过,该文件确实不存在。似乎 mt 库不再是库的一部分 - 或者我错过了什么?
How may I resolve this?
我该如何解决这个问题?
回答by Kilgore Trout
Well, I solved this error on ubuntu 12.04 (x86_64) by the good old scattergun approach
好吧,我通过旧的 scattergun 方法在 ubuntu 12.04 (x86_64) 上解决了这个错误
Installing openvrml with the error "cannot find -lboost_filesystem-mt" after make.
安装 openvrml 后出现错误“找不到 -lboost_filesystem-mt”。
libboost-all-dev. installs 54 different packages. One of 'em must've done the trick, runs fine.
libboost-all-dev。安装 54 个不同的软件包。他们中的一个一定成功了,运行良好。
回答by karlphillip
This version probably doesn't bring multi-threading enabled by default.
这个版本可能没有默认启用多线程。
Try passing -lboost_system
instead of -lboost_system-mt
尝试通过-lboost_system
而不是-lboost_system-mt
Edit:
编辑:
Also it's good to check if the new libs are really inside /usr/local/lib
. You should look for /usr/local/lib/libboost_system.sosince you did not requested the libs to be built with multi-threading. If the file is there, then your $PATH(environment variable) could be missing /usr/local/lib
, and you should update the compilation command so the compiler knows where to find them:
检查新库是否真的在里面也很好/usr/local/lib
。您应该查找/usr/local/lib/libboost_system.so ,因为您没有要求使用多线程构建库。如果文件在那里,那么您的$PATH(环境变量)可能会丢失/usr/local/lib
,您应该更新编译命令,以便编译器知道在哪里可以找到它们:
-L/usr/local/lib -lboost_system-mt
-L/usr/local/lib -lboost_system-mt
回答by Markus
I had a strange encounter with this, too. My solution was a bid odd - but since it worked for me and i didn't read about it anywhere else, here it is. In my case lboost_python3 was missing.
我也遇到过这种奇怪的情况。我的解决方案有点奇怪 - 但因为它对我有用,而且我没有在其他任何地方读到它,所以在这里。在我的情况下, lboost_python3 丢失了。
Hence, i loaded all 54 packages like @Kilgore Trout suggested
因此,我像@Kilgore Trout 建议的那样加载了所有 54 个包
sudo apt-get install libboost-all-dev
Unfortunately, when i looked into the /usr/lib - folder only certain packages were available there. However, when I searched the /usr/lib-folder I got more results - the missing files were all in the /usr/lib/arm-linux-gnueabihf-folder.
不幸的是,当我查看 /usr/lib - 文件夹时,那里只有某些包可用。但是,当我搜索 /usr/lib-folder 时,我得到了更多结果 - 丢失的文件都在 /usr/lib/arm-linux-gnueabihf-folder 中。
I simply copy-pasted all libboost-related files into the /usr/lib-folder et voila - the next time I tried to build anything with the lboost_python3.so, everything worked.
我只是将所有与 libboost 相关的文件复制粘贴到 /usr/lib-folder 中,瞧——下次我尝试用 lboost_python3.so 构建任何东西时,一切正常。
It seems some paths got mixed up or something like this. Hope this helps you or somebody else.
似乎有些路径混淆了或类似的东西。希望这可以帮助您或其他人。
回答by Raphael Bossek
Are your sure the /usr/lib/libboost_system-mt.so
sym-link point to the right file:
您确定/usr/lib/libboost_system-mt.so
符号链接指向正确的文件:
$ realpath /usr/lib/libboost_system-mt.so
Otherwise you have to install the project or use yours distribution package management. For Debian/Ubuntu it would be apt-get install libboost-system1.45-dev
-- but this package does not exists while writing this.
否则你必须安装项目或使用你的分发包管理。对于 Debian/Ubuntu,它会是apt-get install libboost-system1.45-dev
——但是在编写它时这个包不存在。
回答by Frederick Ollinger
I have saucy:
我很调皮:
$ dpkg -S /usr/lib/libboost_system-mt.so
libboost-system1.49-dev: /usr/lib/libboost_system-mt.so
thus, you can do:
因此,你可以这样做:
sudo apt-get install libboost-system1.49-dev
回答by sdaau
Fixed this thanks to @KilgoreTrout's and @user3191035, so here's my notes: I'm on Ubuntu Natty 11.04; my usual state was:
感谢@KilgoreTrout和 @user3191035 解决了这个问题,所以这是我的笔记:我在 Ubuntu Natty 11.04 上;我通常的状态是:
$ dpkg -S libboost_filesystem
libboost-filesystem1.42.0: /usr/lib/libboost_filesystem.so.1.42.0
Then I installed:
然后我安装了:
sudo apt-get install libboost-all-dev # ton of packages
... and after that, I get this:
......在那之后,我得到了这个:
$ dpkg -S libboost_filesystem
libboost-filesystem1.42-dev: /usr/lib/libboost_filesystem-mt.a
libboost-filesystem1.42.0: /usr/lib/libboost_filesystem.so.1.42.0
libboost-filesystem1.42-dev: /usr/lib/libboost_filesystem.so
libboost-filesystem1.42-dev: /usr/lib/libboost_filesystem-mt.so
libboost-filesystem1.42-dev: /usr/lib/libboost_filesystem.a
So, that is where the libboost_filesystem-mt.so
is in this OS...
所以,这就是libboost_filesystem-mt.so
这个操作系统的位置......
回答by ImanV
change libboost_thread-mt to libboost_thread, first find the address of libboost_thread.so and libboost_thread.a then make softlinks to these files in the same address, so it should be
把libboost_thread-mt改成libboost_thread,先找到libboost_thread.so和libboost_thread.a的地址,然后在同一个地址对这些文件做软链接,所以应该是
ln -s /...libboostSourceFiles.../libboost_thread.so /..RequestTOmtFiles.../libboost_thread-mt.so
it works for other libboost -mt files too, like serialization , iostreams, programoptions
它也适用于其他 libboost -mt 文件,如序列化、iostreams、programoptions