我正在尝试为c ++代码生成一个python包装器,它使用Point Cloud Library(PCL)来估计点云的法线。为此我使用boost.python。我能够毫无困难地生成共享库,但是当我尝试在ipython中导入它时,我得到导入错误
undefined symbol: _ZNK5boost6python7objects21py_function_impl_base9max_arityEv
以下是我的问题的详细说明。
首先,我尝试了boost_python文档中的hello world示例。
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
char const* greet()
{
return "hello, world";
}
int square(int number)
{
return number*number;
}
BOOST_PYTHON_MODULE(libhello)
{
using namespace boost::python;
def("greet", greet);
def("square",square);
}
我使用CMakeLists.txt编译上面的代码
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "DEBUG")
#SET(CMAKE_BUILD_TYPE "RELEASE")
#SET(CMAKE_BUILD_TYPE "RELWITHDEBINFO")
#SET(CMAKE_BUILD_TYPE "MINSIZEREL")
ENDIF()
FIND_PACKAGE(Boost 1.54.0)
IF(Boost_FOUND)
INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}" "/usr/include/python2.7")
SET(Boost_USE_STATIC_LIBS OFF)
SET(Boost_USE_MULTITHREADED ON)
SET(Boost_USE_STATIC_RUNTIME OFF)
FIND_PACKAGE(Boost 1.54.0 COMPONENTS python)
ADD_LIBRARY(hello SHARED hello.cpp)
TARGET_LINK_LIBRARIES(hello ${Boost_LIBRARIES})
ELSEIF(NOT Boost_FOUND)
MESSAGE(FATAL_ERROR "Unable to find correct Boost version. Did you set BOOST_ROOT?")
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCXX)
ADD_DEFINITIONS("-Wall")
ELSE()
MESSAGE(FATAL_ERROR "CMakeLists.txt has not been tested/written for your compiler.")
ENDIF()
这完全没有任何问题。 生成的共享库的ldd outbut如下所示:
badami@Zusi:~/Codes/indor_seg/pySegment/libC++/build_hello$ ldd libhello.so
linux-vdso.so.1 => (0x00007fff04695000)
libboost_python-py27.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.54.0 (0x00007f4d0c234000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f4d0bf30000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f4d0bd1a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4d0b955000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4d0b64f000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4d0c68e000)
我可以在ipython环境中导入这个库并毫无困难地调用已定义的方法。
现在,我尝试使用PCL为以下代码重复此示例以获取我的常规估算代码。
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>
#include <pcl/features/integral_image_normal.h>
#include <pcl/visualization/cloud_viewer.h>
int normalEstimation()
{
// load point cloud
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::io::loadPCDFile ("table_scene_mug_stereo_textured.pcd", *cloud);
// estimate normals
pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);
pcl::IntegralImageNormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
ne.setNormalEstimationMethod (ne.AVERAGE_3D_GRADIENT);
ne.setMaxDepthChangeFactor(0.02f);
ne.setNormalSmoothingSize(10.0f);
ne.setInputCloud(cloud);
ne.compute(*normals);
// visualize normals
pcl::visualization::PCLVisualizer viewer("PCL Viewer");
viewer.setBackgroundColor (0.0, 0.0, 0.5);
viewer.addPointCloudNormals<pcl::PointXYZ,pcl::Normal>(cloud, normals);
while (!viewer.wasStopped ())
{
viewer.spinOnce ();
}
return 0;
}
BOOST_PYTHON_MODULE(libpcltest)
{
using namespace boost::python;
def("normalEstimation", normalEstimation);
}
使用CMakeLists.txt,如下所示:
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "DEBUG")
#SET(CMAKE_BUILD_TYPE "RELEASE")
#SET(CMAKE_BUILD_TYPE "RELWITHDEBINFO")
#SET(CMAKE_BUILD_TYPE "MINSIZEREL")
ENDIF()
FIND_PACKAGE(Boost 1.54.0)
IF(Boost_FOUND)
INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}" "/usr/include/python2.7")
SET(Boost_USE_STATIC_LIBS OFF)
SET(Boost_USE_MULTITHREADED ON)
SET(Boost_USE_STATIC_RUNTIME OFF)
FIND_PACKAGE(Boost 1.54.0 COMPONENTS python)
FIND_PACKAGE(PCL 1.7 REQUIRED COMPONENTS common io visualization features)
INCLUDE_DIRECTORIES(${PCL_INCLUDE_DIRS})
LINK_DIRECTORIES(${PCL_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ${PYTHON_LIBRARY_DIRS})
ADD_LIBRARY(pcltest SHARED normal_estimation.cpp)
TARGET_LINK_LIBRARIES(pcltest ${PCL_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
ELSEIF(NOT Boost_FOUND)
MESSAGE(FATAL_ERROR "Unable to find correct Boost version. Did you set BOOST_ROOT?")
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCXX)
ADD_DEFINITIONS("-Wall")
ELSE()
MESSAGE(FATAL_ERROR "CMakeLists.txt has not been tested/written for your compiler.")
ENDIF()
生成的共享库的ldd输出如下:
badami@Zusi:~/Codes/indor_seg/pySegment/libC++/build$ ldd libpcltest.so
linux-vdso.so.1 => (0x00007ffe05793000)
libboost_system.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.54.0 (0x00007f29d38a4000)
libpcl_common.so.1.7 => /usr/lib/libpcl_common.so.1.7 (0x00007f29d35f0000)
libpcl_io.so.1.7 => /usr/lib/libpcl_io.so.1.7 (0x00007f29d3138000)
libpcl_search.so.1.7 => /usr/lib/libpcl_search.so.1.7 (0x00007f29d2d8d000)
libpcl_visualization.so.1.7 => /usr/lib/libpcl_visualization.so.1.7 (0x00007f29d2a36000)
libpcl_features.so.1.7 => /usr/lib/libpcl_features.so.1.7 (0x00007f29d0f38000)
libvtkRendering.so.5.8 => /usr/lib/libvtkRendering.so.5.8 (0x00007f29d0832000)
libvtkFiltering.so.5.8 => /usr/lib/libvtkFiltering.so.5.8 (0x00007f29d02a9000)
libvtkCommon.so.5.8 => /usr/lib/libvtkCommon.so.5.8 (0x00007f29cfd33000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f29cfa2f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f29cf729000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f29cf513000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f29cf14e000)
libboost_thread.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.54.0 (0x00007f29cef38000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f29ced1a000)
libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f29ceb0b000)
libboost_filesystem.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.54.0 (0x00007f29ce8f5000)
libboost_iostreams.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_iostreams.so.1.54.0 (0x00007f29ce6dc000)
libboost_chrono.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_chrono.so.1.54.0 (0x00007f29ce4d5000)
libpcl_io_ply.so.1.7 => /usr/lib/libpcl_io_ply.so.1.7 (0x00007f29ce286000)
libvtkImaging.so.5.8 => /usr/lib/libvtkImaging.so.5.8 (0x00007f29cdc99000)
libvtkIO.so.5.8 => /usr/lib/libvtkIO.so.5.8 (0x00007f29cd518000)
libpng12.so.0 => /usr/lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f29cd2f2000)
libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007f29cd0db000)
libOpenNI2.so.0 => /usr/lib/libOpenNI2.so.0 (0x00007f29cce80000)
libOpenNI.so.0 => /usr/lib/libOpenNI.so.0 (0x00007f29ccc08000)
/lib64/ld-linux-x86-64.so.2 (0x00007f29d3d22000)
libpcl_octree.so.1.7 => /usr/lib/libpcl_octree.so.1.7 (0x00007f29cc81b000)
libpcl_kdtree.so.1.7 => /usr/lib/libpcl_kdtree.so.1.7 (0x00007f29cc4f4000)
libvtkGraphics.so.5.8 => /usr/lib/libvtkGraphics.so.5.8 (0x00007f29cbb38000)
libvtkHybrid.so.5.8 => /usr/lib/libvtkHybrid.so.5.8 (0x00007f29cb656000)
libvtkWidgets.so.5.8 => /usr/lib/libvtkWidgets.so.5.8 (0x00007f29cb282000)
libvtkCharts.so.5.8 => /usr/lib/libvtkCharts.so.5.8 (0x00007f29cafa4000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 (0x00007f29cad15000)
libvtkftgl.so.5.8 => /usr/lib/libvtkftgl.so.5.8 (0x00007f29cab0a000)
libQtGui.so.4 => /usr/lib/x86_64-linux-gnu/libQtGui.so.4 (0x00007f29c9e57000)
libQtCore.so.4 => /usr/lib/x86_64-linux-gnu/libQtCore.so.4 (0x00007f29c9972000)
libgl2ps.so.0 => /usr/lib/libgl2ps.so.0 (0x00007f29c975f000)
libXt.so.6 => /usr/lib/x86_64-linux-gnu/libXt.so.6 (0x00007f29c94f9000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f29c91c4000)
libvtksys.so.5.8 => /usr/lib/libvtksys.so.5.8 (0x00007f29c8f88000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f29c8ce5000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f29c8add000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f29c88c4000)
libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007f29c86b4000)
libpq.so.5 => /usr/lib/libpq.so.5 (0x00007f29c8485000)
libmysqlclient.so.18 => /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18 (0x00007f29c7f4d000)
libvtkDICOMParser.so.5.8 => /usr/lib/libvtkDICOMParser.so.5.8 (0x00007f29c7d34000)
libnetcdf.so.7 => /usr/lib/libnetcdf.so.7 (0x00007f29c79f7000)
libnetcdf_c++.so.4 => /usr/lib/libnetcdf_c++.so.4 (0x00007f29c77da000)
libvtkmetaio.so.5.8 => /usr/lib/libvtkmetaio.so.5.8 (0x00007f29c754d000)
libsqlite3.so.0 => /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007f29c7294000)
libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007f29c703f000)
libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f29c6dcd000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f29c6ba3000)
libavformat.so.54 => /usr/lib/x86_64-linux-gnu/libavformat.so.54 (0x00007f29c6881000)
libavcodec.so.54 => /usr/lib/x86_64-linux-gnu/libavcodec.so.54 (0x00007f29c5b2d000)
libavutil.so.52 => /usr/lib/x86_64-linux-gnu/libavutil.so.52 (0x00007f29c5908000)
libswscale.so.2 => /usr/lib/x86_64-linux-gnu/libswscale.so.2 (0x00007f29c56c1000)
libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007f29c54b0000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f29c52ac000)
libtinyxml.so.2.6.2 => /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2 (0x00007f29c5097000)
libvtkverdict.so.5.8 => /usr/lib/libvtkverdict.so.5.8 (0x00007f29c4e61000)
libvtkParallel.so.5.8 => /usr/lib/libvtkParallel.so.5.8 (0x00007f29c4a5e000)
libvtkexoIIc.so.5.8 => /usr/lib/libvtkexoIIc.so.5.8 (0x00007f29c4814000)
libvtkViews.so.5.8 => /usr/lib/libvtkViews.so.5.8 (0x00007f29c457a000)
libvtkInfovis.so.5.8 => /usr/lib/libvtkInfovis.so.5.8 (0x00007f29c40e2000)
libglapi.so.0 => /usr/lib/x86_64-linux-gnu/libglapi.so.0 (0x00007f29c3eb4000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f29c3ca2000)
libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007f29c3a9f000)
libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f29c3899000)
libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007f29c3697000)
libxcb-glx.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0 (0x00007f29c3480000)
libxcb-dri2.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0 (0x00007f29c327b000)
libxcb-dri3.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0 (0x00007f29c3078000)
libxcb-present.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-present.so.0 (0x00007f29c2e75000)
libxcb-sync.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1 (0x00007f29c2c6f000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f29c2a50000)
libxshmfence.so.1 => /usr/lib/x86_64-linux-gnu/libxshmfence.so.1 (0x00007f29c284e000)
libXxf86vm.so.1 => /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007f29c2648000)
libdrm.so.2 => /usr/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007f29c243a000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f29c21fe000)
libaudio.so.2 => /usr/lib/x86_64-linux-gnu/libaudio.so.2 (0x00007f29c1fe6000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f29c1cde000)
libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f29c1a8d000)
libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6 (0x00007f29c1885000)
libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007f29c1669000)
libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007f29c1459000)
libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f29c124f000)
libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007f29c0ff0000)
libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007f29c0c15000)
libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f29c094a000)
libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f29c0746000)
libgssapi_krb5.so.2 => /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f29c0500000)
libldap_r-2.4.so.2 => /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 (0x00007f29c02af000)
libhdf5_hl.so.7 => /usr/lib/x86_64-linux-gnu/libhdf5_hl.so.7 (0x00007f29c007f000)
libhdf5.so.7 => /usr/lib/x86_64-linux-gnu/libhdf5.so.7 (0x00007f29bfbe3000)
libcurl-gnutls.so.4 => /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 (0x00007f29bf981000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f29bf75f000)
libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f29bf551000)
librtmp.so.0 => /usr/lib/x86_64-linux-gnu/librtmp.so.0 (0x00007f29bf337000)
libgnutls.so.26 => /usr/lib/x86_64-linux-gnu/libgnutls.so.26 (0x00007f29bf079000)
libxvidcore.so.4 => /usr/lib/x86_64-linux-gnu/libxvidcore.so.4 (0x00007f29bed3b000)
libx264.so.142 => /usr/lib/x86_64-linux-gnu/libx264.so.142 (0x00007f29be9a5000)
libvpx.so.1 => /usr/lib/x86_64-linux-gnu/libvpx.so.1 (0x00007f29be5c6000)
libvorbisenc.so.2 => /usr/lib/x86_64-linux-gnu/libvorbisenc.so.2 (0x00007f29be0f7000)
libvorbis.so.0 => /usr/lib/x86_64-linux-gnu/libvorbis.so.0 (0x00007f29bdeca000)
libtheoraenc.so.1 => /usr/lib/x86_64-linux-gnu/libtheoraenc.so.1 (0x00007f29bdc8a000)
libtheoradec.so.1 => /usr/lib/x86_64-linux-gnu/libtheoradec.so.1 (0x00007f29bda71000)
libspeex.so.1 => /usr/lib/x86_64-linux-gnu/libspeex.so.1 (0x00007f29bd858000)
libschroedinger-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libschroedinger-1.0.so.0 (0x00007f29bd594000)
libopus.so.0 => /usr/lib/x86_64-linux-gnu/libopus.so.0 (0x00007f29bd34c000)
libopenjpeg.so.2 => /usr/lib/x86_64-linux-gnu/libopenjpeg.so.2 (0x00007f29bd12a000)
libmp3lame.so.0 => /usr/lib/x86_64-linux-gnu/libmp3lame.so.0 (0x00007f29bce9d000)
libgsm.so.1 => /usr/lib/x86_64-linux-gnu/libgsm.so.1 (0x00007f29bcc8f000)
libva.so.1 => /usr/lib/x86_64-linux-gnu/libva.so.1 (0x00007f29bca78000)
libcgmanager.so.0 => /lib/x86_64-linux-gnu/libcgmanager.so.0 (0x00007f29bc85d000)
libnih.so.1 => /lib/x86_64-linux-gnu/libnih.so.1 (0x00007f29bc645000)
libnih-dbus.so.1 => /lib/x86_64-linux-gnu/libnih-dbus.so.1 (0x00007f29bc43b000)
libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f29bc1f6000)
libVPIC.so.5.8 => /usr/lib/libVPIC.so.5.8 (0x00007f29bbfcd000)
libCosmo.so.5.8 => /usr/lib/libCosmo.so.5.8 (0x00007f29bbd9e000)
libmpi_cxx.so.1 => /usr/lib/libmpi_cxx.so.1 (0x00007f29bbb84000)
libmpi.so.1 => /usr/lib/libmpi.so.1 (0x00007f29bb803000)
libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f29bb49d000)
libvtkalglib.so.5.8 => /usr/lib/libvtkalglib.so.5.8 (0x00007f29bb279000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f29bb075000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f29bae6f000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f29bac31000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f29baa29000)
libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f29ba824000)
libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f29ba5f5000)
libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f29ba3ea000)
libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f29ba1e6000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f29b9fcb000)
liblber-2.4.so.2 => /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 (0x00007f29b9dbc000)
libsasl2.so.2 => /usr/lib/x86_64-linux-gnu/libsasl2.so.2 (0x00007f29b9ba1000)
libgssapi.so.3 => /usr/lib/x86_64-linux-gnu/libgssapi.so.3 (0x00007f29b9963000)
libgcrypt.so.11 => /lib/x86_64-linux-gnu/libgcrypt.so.11 (0x00007f29b96e3000)
libidn.so.11 => /usr/lib/x86_64-linux-gnu/libidn.so.11 (0x00007f29b94b0000)
libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f29b929c000)
libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f29b905a000)
libogg.so.0 => /usr/lib/x86_64-linux-gnu/libogg.so.0 (0x00007f29b8e51000)
liborc-0.4.so.0 => /usr/lib/x86_64-linux-gnu/liborc-0.4.so.0 (0x00007f29b8bcf000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f29b89cc000)
libhwloc.so.5 => /usr/lib/x86_64-linux-gnu/libhwloc.so.5 (0x00007f29b878c000)
libltdl.so.7 => /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007f29b8582000)
libheimntlm.so.0 => /usr/lib/x86_64-linux-gnu/libheimntlm.so.0 (0x00007f29b8379000)
libkrb5.so.26 => /usr/lib/x86_64-linux-gnu/libkrb5.so.26 (0x00007f29b80f1000)
libasn1.so.8 => /usr/lib/x86_64-linux-gnu/libasn1.so.8 (0x00007f29b7e50000)
libhcrypto.so.4 => /usr/lib/x86_64-linux-gnu/libhcrypto.so.4 (0x00007f29b7c1d000)
libroken.so.18 => /usr/lib/x86_64-linux-gnu/libroken.so.18 (0x00007f29b7a08000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f29b7803000)
libnuma.so.1 => /usr/lib/x86_64-linux-gnu/libnuma.so.1 (0x00007f29b75f8000)
libwind.so.0 => /usr/lib/x86_64-linux-gnu/libwind.so.0 (0x00007f29b73cf000)
libheimbase.so.1 => /usr/lib/x86_64-linux-gnu/libheimbase.so.1 (0x00007f29b71c1000)
libhx509.so.5 => /usr/lib/x86_64-linux-gnu/libhx509.so.5 (0x00007f29b6f78000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f29b6d3f000)
现在,当我尝试在ipython中导入此库时,出现以下错误:
In [1]: import libpcltest
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-93c311da18da> in <module>()
----> 1 import libpcltest
ImportError: ./libpcltest.so: undefined symbol: _ZNK5boost6python7objects21py_function_impl_base9max_arityEv
只需在Google中复制粘贴此错误,我就会发现此错误对应于libboost_python.so库的链接错误。 为了证实我的疑问,我检查了我的库libpcltest.so的ldd输出,并意识到确实缺少了libboost_python.so的链接。
为了进一步研究,我然后使用第二个CMakeLists.txt(其中还包括PCL包括目录和PCL库的链接)的配置从第一个示例编译了hello.cpp代码,并且令人惊讶的是生成的共享库的ldd输出没有链接到libboost_python.so
似乎错误与使用libboost_python和PCL有关,但我仍然无法解决它。
请有人帮我解决这个问题。 附:我正在使用ubuntu 14.04,这里使用的所有库都是默认的系统库。
答案 0 :(得分:0)
我想我弄清楚这里出了什么问题。当我检查cmake
的输出时,我得到以下信息:
badami@Zusi:~/Codes/indor_seg/pySegment/libC++/build$ cmake ..
-- Boost version: 1.54.0
-- Boost version: 1.54.0
-- Found the following Boost libraries:
-- python
-- Boost version: 1.54.0
-- Found the following Boost libraries:
-- system
-- filesystem
-- thread
-- date_time
-- iostreams
-- serialization
-- chrono
** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
-- looking for PCL_COMMON
-- looking for PCL_OCTREE
-- looking for PCL_IO
-- looking for PCL_KDTREE
-- looking for PCL_GEOMETRY
-- looking for PCL_SEARCH
-- looking for PCL_VISUALIZATION
-- looking for PCL_SAMPLE_CONSENSUS
-- looking for PCL_FILTERS
-- looking for PCL_FEATURES
-- Configuring done
-- Generating done
-- Build files have been written to: /home/badami/Codes/indor_seg/pySegment/libC++/build
在这里你可以看到它找到Boost库两次,一次来自系统的默认升级安装,一次来自PCL的升级。
因为在我的CMakeLists.txt中,我首先搜索boost库,然后在PCL中,通过在PCL中发现boost库来覆盖boost的python库的发现。
当我在CMakeLists.txt文件中更改订单时
FIND_PACKAGE(Boost 1.54.0 COMPONENTS python)
FIND_PACKAGE(PCL 1.7 REQUIRED COMPONENTS common io visualization features)
到
FIND_PACKAGE(PCL 1.7 REQUIRED COMPONENTS common io visualization features)
FIND_PACKAGE(Boost 1.54.0 COMPONENTS python)
cmake
的相应输出更改为:
badami@Zusi:~/Codes/indor_seg/pySegment/libC++/build$ cmake ..
-- Boost version: 1.54.0
-- Boost version: 1.54.0
-- Found the following Boost libraries:
-- system
-- filesystem
-- thread
-- date_time
-- iostreams
-- serialization
-- chrono
** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
-- looking for PCL_COMMON
-- looking for PCL_OCTREE
-- looking for PCL_IO
-- looking for PCL_KDTREE
-- looking for PCL_GEOMETRY
-- looking for PCL_SEARCH
-- looking for PCL_VISUALIZATION
-- looking for PCL_SAMPLE_CONSENSUS
-- looking for PCL_FILTERS
-- looking for PCL_FEATURES
-- Boost version: 1.54.0
-- Found the following Boost libraries:
-- python
-- Configuring done
-- Generating done
-- Build files have been written to: /home/badami/Codes/indor_seg/pySegment/libC++/build
libboost_python.so成功链接到生成的共享库。
更优雅的解决方案非常受欢迎。