前言:
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()