Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/162.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将PCL链接到Cython C++;模块_Python_C++_C_Cython - Fatal编程技术网

Python 将PCL链接到Cython C++;模块

Python 将PCL链接到Cython C++;模块,python,c++,c,cython,Python,C++,C,Cython,我正在为一个用python编写的模拟器开发一个实时激光雷达数据处理器。 由于数据量巨大,我真的需要c/c++性能。 所以我找到了Cython,它看起来不可思议,只是它不能在编译时包含pcl库 所以我想构建我的.So文件,自己链接pcl,然后在Python包装器中调用库,但仍然没有结果。这是我的setup.py和.pyx Setup.py: #!/usr/bin/env python import sys import os import shutil from distutils.core

我正在为一个用python编写的模拟器开发一个实时激光雷达数据处理器。 由于数据量巨大,我真的需要c/c++性能。 所以我找到了Cython,它看起来不可思议,只是它不能在编译时包含pcl库

所以我想构建我的.So文件,自己链接pcl,然后在Python包装器中调用库,但仍然没有结果。这是我的setup.py和.pyx

Setup.py:

#!/usr/bin/env python

import sys
import os
import shutil

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext


import numpy

setup(cmdclass = {'build_ext': build_ext},
    ext_modules = [Extension("multiply",
                             sources=["cythonBridge.pyx", "Monitor.cpp"],
                             libraries=["myLib"],
                             language="c++",

                             include_dirs=[numpy.get_include()])],
)
cythonBridge.pyx:

#distutils: language = c++


"""
multiply.pyx

simple cython test of accessing a numpy array's data

the C function: c_multiply multiplies all the values in a 2-d array by a scalar, in place.

"""

import cython

# import both numpy and the Cython declarations for numpy
import numpy as np
cimport numpy as np


# declare the interface to the C code
cdef extern void c_multiply (double* array, double value, int m, int n)

@cython.boundscheck(False)
@cython.wraparound(False)
def multiply(np.ndarray[double, ndim=2, mode="c"] input not None, double value):
    """
    multiply (arr, value)

    Takes a numpy array as input, and multiplies each element by value, in place

    param: array -- a 2-d numpy array of np.float64
    param: value -- a number that will be multiplied by each element in the array

    """
    cdef int m, n

    m, n = input.shape[0], input.shape[1]

    c_multiply (&input[0,0], value, m, n)

    return None
错误日志(调用python setup.py安装时):

gcc-pthread-B/home/francesco/anaconda3/envs/carla/compiler\u compat-Wl,--sysroot=/-Wsign compare-DNDEBUG-g-fwrapv-O3-Wall-Wstrict原型-fPIC-I/home/francesco/anaconda3/envs/carla/lib/python3.6/site-packages/numpy/core/include-I/home/francesco/anaconda3/envs/carla/include/python3.6m-c Monitor.cp-o build/temp.linux-x86\u 64-3.6/Monitor.o
Cc1Puls:警告:命令行选项'WraseTrimeType '对于C/Objc有效,但对于C++来说是无效的
在Monitor.cpp中包含的文件中:13:0:
myLib.h:4:10:致命错误:pcl/io/pcd_io.h:没有这样的文件或目录
#包括
^~~~~~~~~~~~~~~~~
编译终止。

是否使用文件
distutils.cfg
?您可以将目录
pcl/io/
添加到[build\u ext]部分下的文件中

[build_ext]
include_dirs= path/to/pcl/io/
或者在setup.py中修改
build\u ext
,例如

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

setup(
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension(".\CythonTutorial\src\helloworld", [".\CythonTutorial\src\helloworld.pyx"])]
)
或者将该标题所在的文件夹添加到列表
Extensions/include\u dirs


很抱歉耽搁了,但我现在还没有互联网(说2020年很奇怪吧?),我试图直接从文件夹中加入pcl,但没有得到我预期的结果,但我可能在没有意识到的情况下更改了项目结构中的一些内容。我马上再试一次,会让你知道的
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

setup(
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension(".\CythonTutorial\src\helloworld", [".\CythonTutorial\src\helloworld.pyx"])]
)