G 找不到Boost库
G++ cannot find boost library
我的命令行编译不好。我的问题是无法编译简单的项目,这取决于Boost。以下是我尝试的日志:
$ g++ -Wall test.cpp -o main
/tmp/ccCTvBYE.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x6b): undefined reference to `boost::system::generic_category()'
test.cpp:(.text+0x77): undefined reference to `boost::system::generic_category()'
test.cpp:(.text+0x83): undefined reference to `boost::system::system_category()'
/tmp/ccCTvBYE.o: In function `boost::asio::error::get_system_category()':
test.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4asio5error19get_system_categoryEv]+0x5): undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status
所以,我找到了添加-lboost_system
或-lboost_system-mt
的说明。我有以下内容:
$ g++ -lboost_system -Wall test.cpp -o main
/usr/bin/ld: cannot find -lboost_system
collect2: error: ld returned 1 exit status
$ g++ -lboost_system-mt -Wall test.cpp -o main
/usr/bin/ld: cannot find -lboost_system-mt
collect2: error: ld returned 1 exit status
我尝试找到boost_system
库。
$ /sbin/ldconfig -p | grep boost_system
libboost_system.so.1.53.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.53.0
然后我尝试了以下
未能成功$ g++ -I"/home/third_party/boost/" -L"/usr/lib/x86_64-linux-gnu/" -lboost_system -Wall test.cpp -o main
/usr/bin/ld: cannot find -lboost_system
collect2: error: ld returned 1 exit status
现在我被卡住了。如何形成命令以编译?
编辑:
以下尝试也没有帮助。
ln -s /usr/lib/x86_64-linux-gnu/libboost_system.so.1.53.0 /usr/lib/x86_64-linux-gnu/libboost_system.so
ldconfig -n /usr/lib/x86_64-linux-gnu/
$ ll /usr/lib/x86_64-linux-gnu/ | grep boost_system
lrwxrwxrwx 1 root root 51 янв. 21 19:47 libboost_system.so -> /usr/lib/x86_64-linux-gnu/libboost_system.so.1.53.0
-rw-r--r-- 1 root root 14536 окт. 13 07:14 libboost_system.so.1.53.0
$ g++ -I"/home/third_party/boost/" -L"/usr/lib/x86_64-linux-gnu/" -lboost_system -Wall -m64 boost_async.cpp -o main
/tmp/ccE20K2W.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x6b): undefined reference to `boost::system::generic_category()'
test.cpp:(.text+0x77): undefined reference to `boost::system::generic_category()'
test.cpp:(.text+0x83): undefined reference to `boost::system::system_category()'
/tmp/ccE20K2W.o: In function `boost::asio::error::get_system_category()':
test.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4asio5error19get_system_categoryEv]+0x5): undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status
如果将链接器指令-lboost_system
放在命令行的末尾,则如下:
g++ -I"/home/third_party/boost/" -L"/usr/lib/x86_64-linux-gnu/" -Wall -m64 boost_async.cpp -o main -lboost_system
这应该解决问题。感谢Colin D Bennett和Wesley.mesquita澄清了这个答案。
相关文章:
- FindPackageHandleStandardArgs.cmake:137 的 CMake 错误(消息):找不到 Boost (缺少:正则表达式)(找到合适的版本"1.72.0",
- CMake 在 Windows 上的自定义位置上找不到 Boost
- 致命错误:找不到'boost/uuid/uuid.hpp'文件
- 找不到请求的Boost库
- CMake 找不到请求的 Boost 库
- C++ CMake 找不到 Boost 1.63(使用 CLion IDE)
- Boost 1.66.0 :找不到提升库:boost_system、boost_filesystem、boost_thr
- 使用 g++-8 编译时找不到 boost/asio/io_context.hpp
- Android Studio 找不到 Boost 标头
- Cmake找不到boost库文件,线程,date_time,iostreams,system
- std::runtime_error:解决方法:在 boost::asio 中找不到主机(权威)
- Rcpp 找不到 Boost 标头
- cmake FindBoost在Windows上使用MinGW构建时找不到Boost库
- CMake 找到了 Boost,但 Make 找不到包含文件
- 交叉编译用于ARM的MongoDB C++驱动程序.找不到Boost库
- 从源代码构建 MySQL 连接器/C++(找不到 Boost 库错误)
- G 找不到Boost库
- Cmake 找不到请求的 Boost 库.- boost_coroutine 1.53
- CMake:如果找不到,则自动进行Boost下载和构建
- Boost找不到未来::然后从演示