【问题标题】:Generating project with PCL (Point Cloud Library) on Mac OS X在 Mac OS X 上使用 PCL(点云库)生成项目
【发布时间】:2014-10-02 19:35:06
【问题描述】:

我按照site 的建议安装了所有依赖项和预编译的 PCL 库。

安装完所有东西后,我想按照this 教程生成一个项目。

执行“make”命令后,我收到几个警告和以下两个错误:

37 warnings generated.
Linking CXX executable pcd_write_test
Undefined symbols for architecture x86_64:
  "pcl::PCDWriter::writeASCII(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, sensor_msgs::PointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&, int)", referenced from:
      pcl::PCDWriter::write(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, sensor_msgs::PointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&, bool) in pcd_write.cpp.o
  "pcl::PCDWriter::writeBinary(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, sensor_msgs::PointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&)", referenced from:
      pcl::PCDWriter::write(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, sensor_msgs::PointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&, bool) in pcd_write.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [pcd_write_test] Error 1
make[1]: *** [CMakeFiles/pcd_write_test.dir/all] Error 2
make: *** [all] Error 2

有人对如何解决这个问题有任何建议吗?

我使用的是 Mac OS X 10.9.4。

【问题讨论】:

  • 我在这个 [thread][1] 中找到了解决方案。 [1]:stackoverflow.com/questions/16318961/…
  • 你最后找到解决办法了吗?我有完全相同的问题。
  • 是的,我在上面的链接中找到了解决方案(第一条评论)。
  • 我看过了,但是更改 C++ 语言方言和/或 C++ 标准库对我来说没有任何改变。

标签: macos linker cmake


【解决方案1】:

在 mac-book pro yosemite(10.10.3) 上,我完成了以下操作 让 pcl 教程 (pcd_write.cpp) 运行。

在 CMakeLists.txt 中

cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(MY_GRAND_PROJECT)
find_package(PCL 1.8 REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(pcd_write_test pcd_write.cpp)
target_link_libraries(pcd_write_test ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})

在构建目录中运行 ccmake .. 给出

 CMAKE_BUILD_TYPE                                                              
 CMAKE_INSTALL_PREFIX             /usr/local                                   
 CMAKE_OSX_ARCHITECTURES                                                       
 CMAKE_OSX_DEPLOYMENT_TARGET                                                   
 CMAKE_OSX_SYSROOT                                                             
 DAVIDSDK_INCLUDE_DIR             DAVIDSDK_INCLUDE_DIR-NOTFOUND                
 DAVIDSDK_LIBRARY                 DAVIDSDK_LIBRARY-NOTFOUND                    
 EIGEN_INCLUDE_DIRS               /opt/local/include/eigen3                    
 ENSENSO_INCLUDE_DIR              ENSENSO_INCLUDE_DIR-NOTFOUND                 
 ENSENSO_LIBRARY                  ENSENSO_LIBRARY-NOTFOUND                     
 LIBUSB_1_INCLUDE_DIR             /opt/local/include                           
 LIBUSB_1_LIBRARY                 /opt/local/lib/libusb-1.0.dylib              
 OPENNI2_INCLUDE_DIRS             OPENNI2_INCLUDE_DIRS-NOTFOUND                
 OPENNI2_LIBRARY                  OPENNI2_LIBRARY-NOTFOUND                     
 OPENNI_INCLUDE_DIRS              /usr/include/ni                              
 OPENNI_LIBRARY                   /usr/lib/libOpenNI.dylib                     
 PCL_COMMON_INCLUDE_DIR           /usr/local/include/pcl-1.8 
 PCL_DIR                          /usr/local/share/pcl-1.8                     
 PCL_IO_INCLUDE_DIR               /usr/local/include/pcl-1.8                   
 PCL_OCTREE_INCLUDE_DIR           /usr/local/include/pcl-1.8

我编译成功的代码

#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
int main(int argc, const char * argv[]) {
    //insert code here..
    pcl::PointCloud<pcl::PointXYZ> cloud;

    cloud.width    = 5;
    cloud.height   = 1;
    cloud.is_dense = false;
    cloud.points.resize (cloud.width * cloud.height);

    for (size_t i = 0; i < cloud.points.size (); ++i){
        cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
        cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
        cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
    }

    pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);
    std::cerr << "Saved " << cloud.points.size () << " data points to test_pcd.pcd." << std::endl;

    for (size_t i = 0; i < cloud.points.size (); ++i)
        std::cerr << "    " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;

    return (0);

    std::cout << "Hello, World!\n";
    return 0;
}

...希望它对某人有用!

尼克

【讨论】:

  • 谢谢!将 cmake 直接绑定到 pcl-1.8 库对我有用!毕竟我有 pcl-1.6 和 pcl-1.8 ......对于 OSX 有用的是用 brew 安装并且让 1.8 工作和运行(我认为,但不确定)......使用 1.8 我得到了 :. /pcd_write_test 将 5 个数据点保存到 test_pcd.pcd。 0.0080142 0.694695 -0.26015 -0.342265 -0.446349 0.214207 0.173687 -0.84253 -0.400481 -0.874475 0.706127 -0.117635 0.908514 -7471 0.408514 -7471
猜你喜欢
  • 2012-10-19
  • 1970-01-01
  • 1970-01-01
  • 2015-04-28
  • 1970-01-01
  • 2014-12-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多