Skip to main content
 首页 » 编程设计

python之关于在我的电脑上安装 PCL 的问题

2024年12月31日8bhlsheji

当我尝试安装 python-pcl(PCL 是用于像激光雷达数据一样呈现的点云库。我按照 https://github.com/strawlab/python-pcl 上的说明进行操作,并且我已经将 travis/pcl-2d-1.8.pc 文件复制到/usr/local/lib/pkgconfig 文件夹)在我的电脑中。我在我的终端输入 AppledeMacBook-Pro-3:python-pcl-0.3.0rc1 apple$ python setup.py install 然后我遇到了下面的问题:

running install 
running bdist_egg 
running egg_info 
writing requirements to python_pcl.egg-info/requires.txt 
writing python_pcl.egg-info/PKG-INFO 
writing top-level names to python_pcl.egg-info/top_level.txt 
writing dependency_links to python_pcl.egg-info/dependency_links.txt 
reading manifest file 'python_pcl.egg-info/SOURCES.txt' 
writing manifest file 'python_pcl.egg-info/SOURCES.txt' 
installing library code to build/bdist.macosx-10.6-x86_64/egg 
running install_lib 
running build_py 
running build_ext 
skipping 'pcl/_pcl_180.cpp' Cython extension (up-to-date) 
building 'pcl._pcl' extension 
/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/apple/miniconda3/include -I/Users/apple/miniconda3/include -DEIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET=1 -I/Users/apple/miniconda3/pkgs/python-3.5.4-h8f450c2_22/lib/python3.5/site-packages/numpy/core/include -I/usr/local/include/pcl-1.8 -I/usr/local/Cellar/openni/1.5.7.10/include/ni -I/usr/local/include/pcl-1.8 -I/usr/local/Cellar/flann/1.9.1_6/include -I/usr/local/include/pcl-1.8 -I/opt/local/include/eigen3 -I/usr/include/ni -I/usr/include/vtk-5.8 -I/usr/local/include/vtk-8.0 -I/usr/local/Cellar/vtk/8.0.1/include -I/Users/apple/miniconda3/pkgs/python-3.5.4-h8f450c2_22/include/python3.5m -c pcl/_pcl_180.cpp -o build/temp.macosx-10.6-x86_64-3.5/pcl/_pcl_180.o 
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the 
      command line to use the libc++ standard library instead 
      [-Wstdlibcxx-not-found] 
pcl/_pcl_180.cpp:447:10: fatal error: 'vector' file not found 
#include <vector> 
         ^~~~~~~~ 

有人说这与我的 Cython 版本有关。但是我已经将 Cython 切换到 0.25.2 版本,仍然无法正常工作。有没有人有同样的问题?非常感谢。对了,我的python版本是3.5.4,我的Mac版本是macOS Mojave 10.14.1

请您参考如下方法:

这是当前 MacOS 安装的一个特殊问题。您可以调整 setup.py 并按照警告建议将 -std=libc++ 添加到编译选项,即

from distutils.core import setup 
from Cython.Build import cythonize 
 
...  some stuff 
 
#passing `-stdlib=libc++` to compiler and linker: 
ext_modules = [Extension(..., 
                         language='c++', 
                         extra_compile_args=["-stdlib=libc++"], # + anything else you need 
                         extra_link_args= ["-stdlib=libc++"] # + anything else you need] 
 
... some more stuff 

我还在链接器选项中添加了 -stdlib=libc++,因为它可能是您遇到的下一个问题。

更多背景:在 MacOS 世界中,长期以来,存在两种不同的 c++ 标准库实现:-libstdc++ 与 gcc 和 libc++ 与 clang 关联。在开始时,-libstdc++ 也默认与 clang-编译器一起使用。但是,情况已不再如此 - 现在甚至都没有安装,这就是无法找到 header 的原因。我不确定为什么您的 clang 版本默认不采用 libc++ - 因此您必须手动将其传递给编译器/链接器。