2012-05-13 10 views
5

私はUbuntu 12.04マシンを使用していますが、私は次の問題があります: CMakeを使ってC++ファイルをコンパイルしようとしていますが、後に "作る" "cmakeの.." 私はエラーを取得する:CMakeを使用してfind_package(PCL 1.2 REQUIRED)が間違ったパスを返します

pcl_openni_grabber.cpp:2:29: fatal error: pcl/point_cloud.h: No such file or directory compilation terminated.

今私のCMakeLists.txtそれは次のようだ:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR) 

project(pcl-openni-grabber) 

find_package(PCL 1.2 REQUIRED) 

include_directories(${PCL_INCLUDE_DIRS}) 
link_directories(${PCL_LIBRARY_DIRS}) 
add_definitions(${PCL_DEFINITIONS}) 

add_executable (pcl_openni_grabber pcl_openni_grabber.cpp) 
target_link_libraries (pcl_openni_grabber ${PCL_LIBRARIES}) 

環境変数PCL_INCLUDE_DIRSが含まれています

/usr/include/pcl-1.5 

問題を理解するための2時間の作業の後、find_package()コマンドで見つけました。実際に私が "cmake .."を実行すると、pclのライブラリ(ポイントクラウドライブラリ)に間違ったパスが返されます。確かにこれはの出力である「cmakeの..」:

-- The C compiler identification is GNU 
-- The CXX compiler identification is GNU 
-- Check for working C compiler: /usr/bin/gcc 
-- Check for working C compiler: /usr/bin/gcc -- works 
-- Detecting C compiler ABI info 
-- Detecting C compiler ABI info - done 
-- Check for working CXX compiler: /usr/bin/c++ 
-- Check for working CXX compiler: /usr/bin/c++ -- works 
-- Detecting CXX compiler ABI info 
-- Detecting CXX compiler ABI info - done 
-- checking for module 'eigen3' 
-- found eigen3, version 3.0.5 
-- Found eigen: /usr/include/eigen3 
-- Boost version: 1.46.1 
-- Found the following Boost libraries: 
-- system 
-- filesystem 
-- thread 
-- date_time 
-- iostreams 
-- checking for module 'flann' 
-- found flann, version 1.7.1 
-- Found Flann: /opt/ros/fuerte/lib/libflann_cpp_s.a 
-- checking for module 'openni-dev' 
-- found openni-dev, version 1.5.2.23~precise 
-- Found openni: /usr/lib/libOpenNI.so 
-- Found libusb-1.0: /usr/include 
-- Found qhull: /usr/lib/libqhull.so 
-- looking for PCL_COMMON 
-- Found PCL_COMMON: /opt/ros/fuerte/lib/libpcl_common.so 
-- looking for PCL_KDTREE 
-- Found PCL_KDTREE: /opt/ros/fuerte/lib/libpcl_kdtree.so 
-- looking for PCL_OCTREE 
-- Found PCL_OCTREE: /opt/ros/fuerte/lib/libpcl_octree.so 
-- looking for PCL_SEARCH 
-- Found PCL_SEARCH: /opt/ros/fuerte/lib/libpcl_search.so 
-- looking for PCL_SAMPLE_CONSENSUS 
-- Found PCL_SAMPLE_CONSENSUS: /opt/ros/fuerte/lib/libpcl_sample_consensus.so 
-- looking for PCL_FILTERS 
-- Found PCL_FILTERS: /opt/ros/fuerte/lib/libpcl_filters.so 
-- looking for PCL_TRACKING 
-- Found PCL_TRACKING: /opt/ros/fuerte/lib/libpcl_tracking.so 
-- looking for PCL_IO 
-- Found PCL_IO: /opt/ros/fuerte/lib/libpcl_io.so 
-- looking for PCL_FEATURES 
-- Found PCL_FEATURES: /opt/ros/fuerte/lib/libpcl_features.so 
-- looking for PCL_REGISTRATION 
-- Found PCL_REGISTRATION: /opt/ros/fuerte/lib/libpcl_registration.so 
-- looking for PCL_SEGMENTATION 
-- Found PCL_SEGMENTATION: /opt/ros/fuerte/lib/libpcl_segmentation.so 
-- looking for PCL_SURFACE 
-- Found PCL_SURFACE: /opt/ros/fuerte/lib/libpcl_surface.so 
-- looking for PCL_VISUALIZATION 
-- Found PCL_VISUALIZATION: /opt/ros/fuerte/lib/libpcl_visualization.so 
-- looking for PCL_KEYPOINTS 
-- Found PCL_KEYPOINTS: /opt/ros/fuerte/lib/libpcl_keypoints.so 
-- Found PCL: /usr/lib/libboost_system-mt.so;/usr/lib/libboost_filesystem-mt.so;/usr/lib/libboost_thread-mt.so;pthread;/usr/lib/libboost_date_time-mt.so;/usr/lib/libboost_iostreams-mt.so;optimized;/opt/ros/fuerte/lib/libpcl_common.so;debug;/opt/ros/fuerte/lib/libpcl_common.so;optimized;/opt/ros/fuerte/lib/libflann_cpp_s.a;debug;/opt/ros/fuerte/lib/libflann_cpp_s-gd.a;optimized;/opt/ros/fuerte/lib/libpcl_kdtree.so;debug;/opt/ros/fuerte/lib/libpcl_kdtree.so;optimized;/opt/ros/fuerte/lib/libpcl_octree.so;debug;/opt/ros/fuerte/lib/libpcl_octree.so;optimized;/opt/ros/fuerte/lib/libpcl_search.so;debug;/opt/ros/fuerte/lib/libpcl_search.so;optimized;/opt/ros/fuerte/lib/libpcl_sample_consensus.so;debug;/opt/ros/fuerte/lib/libpcl_sample_consensus.so;optimized;/opt/ros/fuerte/lib/libpcl_filters.so;debug;/opt/ros/fuerte/lib/libpcl_filters.so;optimized;/opt/ros/fuerte/lib/libpcl_tracking.so;debug;/opt/ros/fuerte/lib/libpcl_tracking.so;/usr/lib/libOpenNI.so;vtkCommon;vtkRendering;vtkHybrid;optimized;/opt/ros/fuerte/lib/libpcl_io.so;debug;/opt/ros/fuerte/lib/libpcl_io.so;optimized;/opt/ros/fuerte/lib/libpcl_features.so;debug;/opt/ros/fuerte/lib/libpcl_features.so;optimized;/opt/ros/fuerte/lib/libpcl_registration.so;debug;/opt/ros/fuerte/lib/libpcl_registration.so;optimized;/opt/ros/fuerte/lib/libpcl_segmentation.so;debug;/opt/ros/fuerte/lib/libpcl_segmentation.so;optimized;/usr/lib/libqhull.so;debug;/usr/lib/libqhull.so;optimized;/opt/ros/fuerte/lib/libpcl_surface.so;debug;/opt/ros/fuerte/lib/libpcl_surface.so;optimized;/opt/ros/fuerte/lib/libpcl_visualization.so;debug;/opt/ros/fuerte/lib/libpcl_visualization.so;optimized;/opt/ros/fuerte/lib/libpcl_keypoints.so;debug;/opt/ros/fuerte/lib/libpcl_keypoints.so (Required is at least version "1.2") 
-- Configuring done 
-- Generating done 
-- Build files have been written to: /home/jacopo/dev/university/prova/build 

あなたが見ることができるように、それはSynapticパッケージマネージャを介してインストールされたROS(ロボットオペレーティングシステム)の特定のパッケージのPCLライブラリーへのパスを返します。 "/ opt/ros"ディレクトリにあります。適切なpclライブラリとインクルードは "/usr/include/pcl.1.5"と "/ usr/lib"にあります。

rosをアンインストールすると、find_packageが正しいパスを返し、問題なくコンパイルしてビルドできるようになります。しかし、私は大学のためのrosを必要とすると同時に私はcmakeが必要です、私はどのようにcmakeがrosをインストールして働くことができますか?何か案が?

答えて

7

あなたはfind_packageコマンドの検索パスの微調整ができます。

find_package(PCL 1.2 REQUIRED PATHS /usr NO_DEFAULT_PATH) 

これは、ビットブルートフォースかもしれませんが。 CMakeがパッケージを検索するときに、/optを考慮から除外するより良い方法を見つけることができます。

脇に、link_directoriesを使用しないでください。ドキュメンテーションは、それが通常必要でない理由を示しています。

+0

非常に感謝のフレーザー、それは働いた:) – yorsh

関連する問題