当终端中的一切正常时,为什么Xcode无法链接PCL?

时间:2014-01-07 06:22:46

标签: c++ xcode macos linker point-cloud-library

我正在使用CMake(2.8-12)为我的代码生成项目和makefile,它与Mac OS X上的boost和点云库(PCL)动态链接(10.9)。在过去,我主要创建并使用Eclipse项目文件来编辑和编译代码。我现在想看到Xcode能够处理构建我的可执行文件的相同任务。 Xcode成功编译代码,但无法与PCL链接(见下文)。

要明确:

  • CMake可以为我生成Xcode项目文件。
  • Xcode使用的是与我在终端(和Eclipse)中使用的相同的编译器(/ usr / bin / clang ++)。
  • 使用Xcode时,链接器会失败并抱怨与PCL相关的呼叫缺少符号。
  • 所有库都已链接到libc ++,如前所述,当我使用基本的makefile时,它确实可以正常工作。

有没有办法找出,为什么Xcode找不到这些符号,即使所有PCL库似乎都包含在链接器命令中? CMake正在将完整路径移交给每个动态库。这可能是个问题吗?

如果您遇到任何类似问题,我们将非常感谢您的帮助。

链接器错误:

 Ld /Users/chris/dev/intern/quick_vis-dev/build-xcode/Debug/quick_vis normal x86_64
    cd /Users/chris/dev/intern/quick_vis-dev/quick_vis
    setenv MACOSX_DEPLOYMENT_TARGET 10.9
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/chris/dev/intern/quick_vis-dev/build-xcode/Debug -L/usr/local/lib/Debug -L/usr/local/lib -L/Users/chris/dev/extern/lib/Debug -L/Users/chris/dev/extern/lib -F/Users/chris/dev/intern/quick_vis-dev/build-xcode/Debug -F/usr/local/Cellar/qt/4.8.5/lib -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks -filelist /Users/chris/dev/intern/quick_vis-dev/build-xcode/quick_vis.build/Debug/quick_vis.build/Objects-normal/x86_64/quick_vis.LinkFileList -Xlinker -rpath -Xlinker /usr/local/lib -Xlinker -rpath -Xlinker /Users/chris/dev/extern/lib -mmacosx-version-min=10.9 -DGL_GLEXT_PROTOTYPES -Wl,-search_paths_first -Wl,-headerpad_max_install_names -framework OpenGL -DGL_GLEXT_PROTOTYPES -framework AGL -framework OpenGL -framework QtOpenGL /usr/local/Cellar/qt/4.8.5/lib/libQtUiTools_debug.a -framework QtGui -framework QtXml -framework QtCore /usr/local/lib/libboost_system-mt.dylib /usr/local/lib/libboost_filesystem-mt.dylib /usr/local/lib/libboost_thread-mt.dylib /usr/local/lib/libboost_date_time-mt.dylib /usr/local/lib/libboost_iostreams-mt.dylib /usr/local/lib/libboost_serialization-mt.dylib /usr/local/lib/vtk-5.10/libvtkCommon.5.10.1.dylib /usr/local/lib/vtk-5.10/libvtkRendering.5.10.1.dylib /usr/local/lib/vtk-5.10/libvtkHybrid.5.10.1.dylib /usr/local/lib/vtk-5.10/libvtkCharts.5.10.1.dylib /Users/chris/dev/extern/lib/libpcl_io.dylib /Users/chris/dev/extern/lib/libpcl_octree.dylib /Users/chris/dev/extern/lib/libpcl_filters.dylib /Users/chris/dev/extern/lib/libpcl_sample_consensus.dylib /usr/local/Cellar/flann/1.8.4/lib/libflann_cpp_s.a /Users/chris/dev/extern/lib/libpcl_search.dylib /Users/chris/dev/extern/lib/libpcl_kdtree.dylib /Users/chris/dev/extern/lib/libpcl_features.dylib /Users/chris/dev/extern/lib/libpcl_keypoints.dylib /Users/chris/dev/extern/lib/libpcl_ml.dylib /Users/chris/dev/extern/lib/libpcl_outofcore.dylib /Users/chris/dev/extern/lib/libpcl_visualization.dylib /Users/chris/dev/extern/lib/libpcl_registration.dylib /Users/chris/dev/extern/lib/libpcl_segmentation.dylib /usr/local/lib/libqhullstatic.a /usr/local/lib/libqhull.dylib /Users/chris/dev/extern/lib/libpcl_surface.dylib /usr/local/lib/vtk-5.10/libvtkViews.5.10.1.dylib /usr/local/lib/vtk-5.10/libvtkInfovis.5.10.1.dylib /usr/local/lib/vtk-5.10/libvtkWidgets.5.10.1.dylib /usr/local/lib/vtk-5.10/libvtkHybrid.5.10.1.dylib /usr/local/lib/vtk-5.10/libvtkVolumeRendering.5.10.1.dylib /usr/local/lib/vtk-5.10/libvtkRendering.5.10.1.dylib -framework QtGui /usr/local/lib/vtk-5.10/libvtkGraphics.5.10.1.dylib /usr/local/lib/vtk-5.10/libvtkImaging.5.10.1.dylib -framework QtSql -framework QtCore -lobjc /usr/local/lib/vtk-5.10/libvtkIO.5.10.1.dylib /usr/local/lib/vtk-5.10/libvtkFiltering.5.10.1.dylib /usr/local/lib/vtk-5.10/libvtkCommon.5.10.1.dylib /usr/local/lib/vtk-5.10/libvtksys.5.10.1.dylib -lm -Xlinker -dependency_info -Xlinker /Users/chris/dev/intern/quick_vis-dev/build-xcode/quick_vis.build/Debug/quick_vis.build/Objects-normal/x86_64/quick_vis_dependency_info.dat -o /Users/chris/dev/intern/quick_vis-dev/build-xcode/Debug/quick_vis

ld: warning: directory not found for option '-L/usr/local/lib/Debug'
ld: warning: directory not found for option '-L/Users/chris/dev/extern/lib/Debug'
Undefined symbols for architecture x86_64:
  "pcl::PCLBase<pcl::PointNormal>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)", referenced from:
      vtable for pcl::GreedyProjectionTriangulation<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::PCLSurfaceBase<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::PCLBase<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::MeshConstruction<pcl::PointNormal> in QVMeshTriangulationPlugin.o
  "pcl::PCLBase<pcl::PointNormal>::setIndices(boost::shared_ptr<std::__1::vector<int, std::__1::allocator<int> > const> const&)", referenced from:
      vtable for pcl::GreedyProjectionTriangulation<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::PCLSurfaceBase<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::PCLBase<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::MeshConstruction<pcl::PointNormal> in QVMeshTriangulationPlugin.o
  "pcl::PCLBase<pcl::PointNormal>::setIndices(boost::shared_ptr<std::__1::vector<int, std::__1::allocator<int> > > const&)", referenced from:
      vtable for pcl::GreedyProjectionTriangulation<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::PCLSurfaceBase<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::PCLBase<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::MeshConstruction<pcl::PointNormal> in QVMeshTriangulationPlugin.o
  "pcl::PCLBase<pcl::PointNormal>::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)", referenced from:
      vtable for pcl::GreedyProjectionTriangulation<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::PCLSurfaceBase<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::PCLBase<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::MeshConstruction<pcl::PointNormal> in QVMeshTriangulationPlugin.o
  "pcl::PCLBase<pcl::PointNormal>::initCompute()", referenced from:
      pcl::MeshConstruction<pcl::PointNormal>::reconstruct(pcl::PolygonMesh&) in QVMeshTriangulationPlugin.o
      pcl::MeshConstruction<pcl::PointNormal>::reconstruct(std::__1::vector<pcl::Vertices, std::__1::allocator<pcl::Vertices> >&) in QVMeshTriangulationPlugin.o
  "pcl::PCLBase<pcl::PointNormal>::deinitCompute()", referenced from:
      pcl::MeshConstruction<pcl::PointNormal>::reconstruct(pcl::PolygonMesh&) in QVMeshTriangulationPlugin.o
      pcl::MeshConstruction<pcl::PointNormal>::reconstruct(std::__1::vector<pcl::Vertices, std::__1::allocator<pcl::Vertices> >&) in QVMeshTriangulationPlugin.o
  "pcl::PCLBase<pcl::PointNormal>::setInputCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointNormal> const> const&)", referenced from:
      vtable for pcl::GreedyProjectionTriangulation<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::PCLSurfaceBase<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::PCLBase<pcl::PointNormal> in QVMeshTriangulationPlugin.o
      vtable for pcl::MeshConstruction<pcl::PointNormal> in QVMeshTriangulationPlugin.o
  "pcl::PCLBase<pcl::PointNormal>::PCLBase()", referenced from:
      pcl::PCLSurfaceBase<pcl::PointNormal>::PCLSurfaceBase() in QVMeshTriangulationPlugin.o
  "pcl::PCLBase<pcl::PointXYZ>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)", referenced from:
      vtable for pcl::ConcaveHull<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::PCLSurfaceBase<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::PCLBase<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::MeshConstruction<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::Feature<pcl::PointXYZ, pcl::Normal> in QVPointDatabase.o
      vtable for pcl::PCLBase<pcl::PointXYZ> in QVPointDatabase.o
      vtable for pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> in QVPointDatabase.o
      ...
  "pcl::PCLBase<pcl::PointXYZ>::setIndices(boost::shared_ptr<std::__1::vector<int, std::__1::allocator<int> > const> const&)", referenced from:
      vtable for pcl::ConcaveHull<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::PCLSurfaceBase<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::PCLBase<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::MeshConstruction<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::Feature<pcl::PointXYZ, pcl::Normal> in QVPointDatabase.o
      vtable for pcl::PCLBase<pcl::PointXYZ> in QVPointDatabase.o
      vtable for pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> in QVPointDatabase.o
      ...
  "pcl::PCLBase<pcl::PointXYZ>::setIndices(boost::shared_ptr<std::__1::vector<int, std::__1::allocator<int> > > const&)", referenced from:
      vtable for pcl::ConcaveHull<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::PCLSurfaceBase<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::PCLBase<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::MeshConstruction<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::Feature<pcl::PointXYZ, pcl::Normal> in QVPointDatabase.o
      vtable for pcl::PCLBase<pcl::PointXYZ> in QVPointDatabase.o
      vtable for pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> in QVPointDatabase.o
      ...
  "pcl::PCLBase<pcl::PointXYZ>::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)", referenced from:
      vtable for pcl::ConcaveHull<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::PCLSurfaceBase<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::PCLBase<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::MeshConstruction<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::Feature<pcl::PointXYZ, pcl::Normal> in QVPointDatabase.o
      vtable for pcl::PCLBase<pcl::PointXYZ> in QVPointDatabase.o
      vtable for pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> in QVPointDatabase.o
      ...
  "pcl::PCLBase<pcl::PointXYZ>::initCompute()", referenced from:
      pcl::MeshConstruction<pcl::PointXYZ>::reconstruct(pcl::PolygonMesh&) in QVCenterlineGenerator.o
      pcl::MeshConstruction<pcl::PointXYZ>::reconstruct(std::__1::vector<pcl::Vertices, std::__1::allocator<pcl::Vertices> >&) in QVCenterlineGenerator.o
      pcl::Feature<pcl::PointXYZ, pcl::Normal>::initCompute() in QVPointDatabase.o
      pcl::Feature<pcl::PointXYZ, pcl::Normal>::initCompute() in QVMeshNormalEstimationPlugin.o
  "pcl::PCLBase<pcl::PointXYZ>::deinitCompute()", referenced from:
      pcl::MeshConstruction<pcl::PointXYZ>::reconstruct(pcl::PolygonMesh&) in QVCenterlineGenerator.o
      pcl::MeshConstruction<pcl::PointXYZ>::reconstruct(std::__1::vector<pcl::Vertices, std::__1::allocator<pcl::Vertices> >&) in QVCenterlineGenerator.o
  "pcl::PCLBase<pcl::PointXYZ>::setInputCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&)", referenced from:
      vtable for pcl::ConcaveHull<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::PCLSurfaceBase<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::PCLBase<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::MeshConstruction<pcl::PointXYZ> in QVCenterlineGenerator.o
      vtable for pcl::Feature<pcl::PointXYZ, pcl::Normal> in QVPointDatabase.o
      vtable for pcl::PCLBase<pcl::PointXYZ> in QVPointDatabase.o
      vtable for pcl::EuclideanClusterExtraction<pcl::PointXYZ> in QVMeshClusteringPlugin.o
      ...
  "pcl::PCLBase<pcl::PointXYZ>::PCLBase()", referenced from:
      pcl::PCLSurfaceBase<pcl::PointXYZ>::PCLSurfaceBase() in QVCenterlineGenerator.o
      pcl::Feature<pcl::PointXYZ, pcl::Normal>::Feature() in QVPointDatabase.o
      pcl::EuclideanClusterExtraction<pcl::PointXYZ>::EuclideanClusterExtraction() in QVMeshClusteringPlugin.o
      pcl::Feature<pcl::PointXYZ, pcl::Normal>::Feature() in QVMeshNormalEstimationPlugin.o
  "pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)", referenced from:
      pcl::ConcaveHull<pcl::PointXYZ>::setDimension(int) in QVCenterlineGenerator.o
      void pcl::detail::FieldMapper<pcl::PointXYZ>::operator()<pcl::fields::x>() in QVModelProcessor.o
      void pcl::detail::FieldMapper<pcl::PointXYZ>::operator()<pcl::fields::y>() in QVModelProcessor.o
      void pcl::detail::FieldMapper<pcl::PointXYZ>::operator()<pcl::fields::z>() in QVModelProcessor.o
      pcl::Feature<pcl::PointXYZ, pcl::Normal>::initCompute() in QVPointDatabase.o
      pcl::SampleConsensus<pcl::PointXYZ>::refineModel(double, unsigned int) in QVMeshClusteringPlugin.o
      pcl::SampleConsensusModel<pcl::PointXYZ>::computeVariance() in QVMeshClusteringPlugin.o
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

1 个答案:

答案 0 :(得分:0)

简短回答:仔细检查链接库后,结果发现其中一个确实缺失,并且未包含在链接器命令中。

然而,更有趣的是这是如何发生的:

当与PCL链接时,CMake中用于查找所需PCL库(例如${PCL_COMMON_LIBRARIES})的环境变量也将包含对所有PCL自身依赖项的引用(例如VTK,Boost)。最终,链接器面临着多次查看同一个库,这大大增加了我的构建时间。因此,我决定通过调用:

手动删除重复项
list(REMOVE_DUPLICATES PCL_ALL_REQUIRED_LIBRARIES)

结果,我的构建时间减少了,而且我很高兴。我不知道的是,关键字debugoptimized以某种方式保留在此PCL库列表中,导致一些引用的PCL库仅被放入DEBUG Xcode构建配置,其中一些配置到RELEASE构建配置中,这是我创建make文件时不会发生的事情。

我最终通过从PCL库列表中删除所有这些关键字来解决这个问题:

list(REMOVE_ITEM PCL_ALL_REQUIRED_LIBRARIES "debug")
list(REMOVE_ITEM PCL_ALL_REQUIRED_LIBRARIES "optimized")