2014-10-02 73 views
5

我安裝了它們的site上建議的所有依賴項和預編譯的PCL庫。在Mac OS X上使用PCL(點雲庫)生成項目

我安裝了一切後,我想生成一個項目,遵循this教程。

執行「製作」命令我得到一些警告和下面的兩個錯誤後:

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。

+0

我在這個[thread] [1]找到了解決方案。 [1]:http://stackoverflow.com/questions/16318961/how-do-i-link-pcl-library-properly-for-use-within-an-objective-c-app-compiled-in – Silex 2014-10-05 22:50:02

+0

您是否最終找到解決方案?我有完全一樣的問題。 – JessMcintosh 2014-11-10 14:26:04

+0

是的,我在上面的鏈接中找到了解決方案(第一條評論)。 – Silex 2014-11-10 17:52:11

回答

3

在mac-book pro優勝美地(10.10.3)我已經完成了以下 以獲得pcl-tutorial(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; 
} 

...希望其有用的人!

nik

+0

謝謝!將cmake直接綁定到pcl-1.8庫爲我工作!在所有的cruft中,我有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 -0.598159 0.744714 – Orbitus007 2017-07-13 15:12:34