前言:
ubuntu 16.04
剛裝的PCL 1.8.1
Qt環境下c++開發
使用CMAKE
我做了什麼呢:
在程序裏include <pcl/...> (pcl的庫)
如:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <pcl/io/pcd_io.h>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
然後遇到了:
main.cpp:(.text+0x86): undefined reference to `boost::system::generic_category()'
main.cpp:(.text+0x92): undefined reference to `boost::system::system_category()'
問題出現原因是:PCL庫裏用到boost但編譯環境沒找到boost庫
解決辦法:把以下加到CMakeList.txt
add_executable(${PROJECT_NAME} main.cpp)
FIND_PACKAGE(Boost 1.55.0 REQUIRED COMPONENTS system filesystem)
if(Boost_FOUND)
MESSAGE("Hint:Boost FOUND")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${Boost_LIBRARIES})
endif()