【发布时间】:2020-01-02 10:36:07
【问题描述】:
有很多类似的帖子,我面临同样的错误,但没有一个解决方案对我有用。请不要认为这是重复的。在尝试了所有建议的解决方案后,我正在与您联系。
我正在尝试从使用 boost 库的 c++ 文件创建一个 python 库
#include <boost/thread.hpp>
我已经通过命令在 Ubuntu 中安装了 Boost
./bootstrap.sh --prefix=/usr/local
然后
./b2 install --with-thread
。
现在,当我尝试使用#include <boost/thread.hpp> 运行文件时,它给了我这个错误提示
src/main.cpp:2:10:致命错误:boost/thread.hpp:没有这样的文件或目录
我错过了什么吗?谁能帮我解决这个问题。
错误
同时粘贴错误说明,以防有人不方便查看图像
Failed building wheel for python-example
Running setup.py clean for python-example
Failed to build python-example
Installing collected packages: python-example
Running setup.py install for python-example ... error
Complete output from command /home/hmi/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-req-build-h4742spy /setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-3l3u7dxm/install-record.txt --single-version-externally- managed --compile:
running install
running build
running build_ext
gcc -pthread -B /home/hmi/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/hmi/anaconda3/include/python3.7m -c /tmp/tmpbv27mdxm.cpp -o tmp/tmpbv27mdxm.o -std=c++17
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/hmi/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/hmi/anaconda3/include/python3.7m -c /tmp/tmps2iqs0qp.cpp -o tmp/tmps2iqs0qp.o -fvisibility=hidden
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
building 'python_example' extension
creating build
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/src
gcc -pthread -B /home/hmi/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/hmi/anaconda3/include -I/home/hmi/anaconda3/include -I/home/hmi/anaconda3/include/python3.7m -c src/main.cpp -o build/temp.linux-x86_64-3.7/src/main.o -DVERSION_INFO="0.0.1" -std=c++17 -fvisibility=hidden
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
src/main.cpp:2:10: fatal error: boost/thread.hpp: No such file or directory
#include <boost/thread.hpp>
^~~~~~~~~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
我也试过这个命令
g++ -std=c++11 main.cpp -lpthread -lboost_system -lboost_thread -o main
。但类似的结果。
操作系统:Ubuntu 18.04
Boost 版本:1.55
【问题讨论】:
-
你有什么理由不能简单地使用系统包吗?
apt install libboost-thread-dev(同样适用于您可能需要的其他库) -
您是否使用
apt安装了boost-thread 源代码? -
不。我下载了文件并使用引导程序./b2 进行了操作。使用 apt 对我没有帮助。访问权限问题
-
Boost 1.55,你知道那是几岁吗?此外,C++ 有自己的线程支持,现代 C++ 编译器不需要来自 Boost 的线程支持。
-
1.
thread.hpp安装在哪里? (sudo updatedb加上locate thread.hpp应该会告诉你)。 2. 你的包含路径是什么(g++ -E -Wp,-v -xc++ /dev/null)
标签: python c++ boost ubuntu-18.04