Qt裏使用PCL庫時候遇到的編譯問題:undefined reference to 'boost::system::generic_category()'的解決方法

前言:

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()


發佈了39 篇原創文章 · 獲贊 34 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章