本文介绍了在Mac OS X上使用PCL(点云库)生成项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照建议在其站点上安装了所有依赖项和预编译的PCL库. .

I installed all the dependencies and the pre-compiled PCL library as it suggested on their site.

安装完所有内容后,我想根据此项目生成一个项目教程.

After I installed everything I wanted to generate a project following this tutorial.

执行"make"命令后,我收到一些警告和以下两个错误:

After executing the 'make' command I get several warnings and the following two errors:

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

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

Anybody has any suggestions how to fix this?

我正在使用Mac OS X 10.9.4.

I am using Mac OS X 10.9.4.

推荐答案

在mac-book pro优胜美地(10.10.3)上,我已完成以下操作使pcl-tutorial(pcd_write.cpp)运行.

on a mac-book pro yosemite(10.10.3) i have done the followingto get the pcl-tutorial (pcd_write.cpp) running.

在CMakeLists.txt中

in the 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 ..给出

running ccmake .. in build-directory gives

 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;
}

...希望对某人有用!

...hope its usefull for someone!

nik

这篇关于在Mac OS X上使用PCL(点云库)生成项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-30 03:29