boost/thread.hpp: 没有那个文件或目录
boost/thread.hpp: No such file or directory
有许多类似的帖子与我面临的错误相同,但 none 的解决方案对我有用。请不要认为这是重复的。在尝试了所有建议的解决方案后,我与您联系。
我正在尝试从 c++ 文件创建一个 python 库,该文件使用带有
的 boost 库
#include <boost/thread.hpp>
我已经通过命令
在 Ubuntu 中安装了 Boost
./bootstrap.sh --prefix=/usr/local
然后是
./b2 install --with-thread
。
现在,当我尝试 运行 带有 #include <boost/thread.hpp>
的文件时,它给我这个错误提示
src/main.cpp:2:10: fatal error: boost/thread.hpp: No such file or directory
我是不是漏掉了什么?谁能帮我解决这个问题。
错误
我将附上相同的屏幕截图以供查看。
同时粘贴错误描述以防有人不喜欢查看图片
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
。但结果相似。
OS : Ubuntu 18.04
提升版本:1.55
我现在已经使用 Botje 提到的命令解决了它,但是使用了 sudo。
sudo apt install libboost-thread-dev
但是我不想通过root来做。所以我克制了它的使用。但是现在我没有找到任何其他方法。我很高兴知道其他解决方案是否有效
有许多类似的帖子与我面临的错误相同,但 none 的解决方案对我有用。请不要认为这是重复的。在尝试了所有建议的解决方案后,我与您联系。
我正在尝试从 c++ 文件创建一个 python 库,该文件使用带有
的 boost 库
#include <boost/thread.hpp>
我已经通过命令
在 Ubuntu 中安装了 Boost
./bootstrap.sh --prefix=/usr/local
然后是
./b2 install --with-thread
。
现在,当我尝试 运行 带有 #include <boost/thread.hpp>
的文件时,它给我这个错误提示
src/main.cpp:2:10: fatal error: boost/thread.hpp: No such file or directory
我是不是漏掉了什么?谁能帮我解决这个问题。
错误
我将附上相同的屏幕截图以供查看。
同时粘贴错误描述以防有人不喜欢查看图片
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
。但结果相似。
OS : Ubuntu 18.04
提升版本:1.55
我现在已经使用 Botje 提到的命令解决了它,但是使用了 sudo。
sudo apt install libboost-thread-dev
但是我不想通过root来做。所以我克制了它的使用。但是现在我没有找到任何其他方法。我很高兴知道其他解决方案是否有效