Point Cloud Library1.8(PCL)のプロジェクト作成


PCLをインストールしてみました。
Unaさんのやり方でほとんどOKですが、一部気になるところがあったのでメモ

※現在更新中

サンプルプログラムの作成

サンプルプログラムの作成(WinApi)

  • 32bit用環境構築が必要?
  • CMakeListsからWin32Api用の設定を行う必要があります

以下のコードを書き込んでCMake
- 自分用のコードなので非常に汚いです。

CMakeLists.txt
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(MY_GRAND_PROJECT)
find_package(PCL 1.8 REQUIRED COMPONENTS common io)
set(GUI_TYPE WIN32)
set(HDR)
set(RES)

add_definitions(-DWIN32 -D_WINDOWS -D_UNICODE -DUNICODE)
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})

set(SRC pcd_write.cpp)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,5.01")

add_custom_target(${CMAKE_PROJECT}_HEADERS SOURCES ${HDR})

add_executable(${CMAKE_PROJECT_NAME} ${GUI_TYPE} ${SRC} ${RES})
pcd_write.cpp
#include <Windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    MessageBox(NULL, TEXT("Kitty on your lap"),
        TEXT("メッセージボックス"),
        MB_OK | MB_ICONINFORMATION);
    return 0;
}

参考:
building a Win32 application with cmake [SOLVED]

エラー

CMP0054

  • CMakeでpclをConfigureするときに発生
CMake Warning (dev) at C:/Program Files/VTK/lib/cmake/vtk-7.0/VTKTargets.cmake:28 (if):
  Policy CMP0054 is not set: Only interpret if() arguments as variables or
  keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  Quoted variables like "" will no longer be dereferenced when the policy is
  set to NEW.  Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
  C:/Program Files/VTK/lib/cmake/vtk-7.0/VTKConfig.cmake:68 (include)
  CMakeLists.txt:362 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at C:/Program Files/VTK/lib/cmake/vtk-7.0/VTKTargets.cmake:33 (if):
  Policy CMP0054 is not set: Only interpret if() arguments as variables or
  keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  Quoted variables like "" will no longer be dereferenced when the policy is
  set to NEW.  Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
  C:/Program Files/VTK/lib/cmake/vtk-7.0/VTKConfig.cmake:68 (include)
  CMakeLists.txt:362 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.
  • 調べた結果、このエラーは基本的に無視してよいとのこと ※参考

C4819

  • VisualStudioでビルドしているときに以下のエラーを発見
warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 
  • 無視しても一応動きました

Error C2589

  • 以下のようなエラーを発見
  • std::numeric_limits::max()が理解されない事案が多数発生
  • CMakeを使ってプロジェクトを作成しないため発生した
Error  8   error C2059: syntax error : '::'

Error  7   error C2589: '(' : illegal token on right side of '::'
  • 一応関数の上に#undef maxと入力することで消えるが。。。 参考