Question

I am using CMake (2.8-12) to generate project and makefiles for my code, which dynamically links with boost and the point cloud library (PCL) on Mac OS X (10.9). In the past I have mostly created and used Eclipse project files for editing and compiling the code. I would now like to see Xcode being able to handle the same task of building my executable as well. Xcode successfully compiles the code, but is unable to link with PCL (see below).

To be clear:

  • CMake can generate the Xcode project file for me.
  • Xcode is using the same compiler (/usr/bin/clang++) as I used in the terminal (and with Eclipse).
  • When using Xcode, the linker fails and complains about missing symbols for calls related to PCL.
  • All libraries have been linked to libc++ and as said before, it does work fine, when I use basic makefiles.

Is there some way to find out, why Xcode can not find these symbols, even though all PCL libraries seem to be included for the linker command? CMake is handing over the full path to every dynamic library. Could this be a problem?

If you have experienced any similar issue, your help would be very much appreciated.

Linker errors:

 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)
Was it helpful?

Solution

Short answer: After carefully reviewing the linked libraries, it turned out one of them was indeed missing and not included within the linker command.

More interesting, however, is the fact how this had happened:

When linking with PCL, the environment variables used in CMake to find the required PCL libraries (e.g. ${PCL_COMMON_LIBRARIES}) will also contain references to all of PCL's own dependencies (e.g. VTK, Boost). Eventually, the linker is confronted with looking at the same library multiple times, which had increased my build time considerably. Thus, I had decided to manually remove duplicates by calling:

list(REMOVE_DUPLICATES PCL_ALL_REQUIRED_LIBRARIES)

As a result, my build time was reduced and I was happy. What I didn't know was, that somehow the keywords debug and optimized where remaining in this list of PCL libraries, resulting in some of the referenced PCL libraries being placed only into the DEBUG Xcode build config and some of them into the RELEASE build config, something that doesn't happen, when I created make files.

I solved this eventually by removing all such keywords from the list of PCL libraries:

list(REMOVE_ITEM PCL_ALL_REQUIRED_LIBRARIES "debug")
list(REMOVE_ITEM PCL_ALL_REQUIRED_LIBRARIES "optimized")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top