首页 > 解决方案 > 如何使用 qmake 将 pcl 库成功添加到 qt 项目中

问题描述

我正在尝试使用 qmake 将 pcl 库包含到我的 qt 应用程序项目中。我发现了一些类似的问题,但是没有一个答案有助于解决我的问题。

我试图将来自 pcl lib 的路径以及 pcl 使用的 3rd 方库添加到 .pro 文件中。这是我的 .pro 文件的包含行。

win32:CONFIG(release, debug|release): LIBS += -LD:/Libraries/PCL_1.6.0/lib
win32:CONFIG(release, debug|release): LIBS += -LD:/Libraries/PCL_1.6.0/3rdParty/Eigen/bin
win32:CONFIG(release, debug|release): LIBS += -LD:/Libraries/PCL_1.6.0/3rdParty/Boost/lib

INCLUDEPATH +=  D:/Libraries/PCL_1.6.0/include/pcl-1.6
DEPENDPATH += D:/Libraries/PCL_1.6.0/include/pcl-1.6

INCLUDEPATH +=  D:/Libraries/PCL_1.6.0/3rdParty/Eigen/include
DEPENDPATH += D:/Libraries/PCL_1.6.0/3rdParty/Eigen/include

INCLUDEPATH +=  D:/Libraries/PCL_1.6.0/3rdParty/Boost/include
DEPENDPATH += D:/Libraries/PCL_1.6.0/3rdParty/Boost/include

在那之后,我只是想把这个包含到我的一个文件中:

include pcl/io/pcd_io.h

这些是我回来的错误:

D:\Libraries\PCL_1.6.0\3rdParty\Eigen\include\Eigen\src\Core\products\GeneralBlockPanelKernel.h:604:错误:无法使用 'const char [2] 找到字符串文字运算符 'operator""X' ', 'long long unsigned int' 参数 EIGEN_ASM_COMMENT("mybegin2");

D:\Libraries\PCL_1.6.0\3rdParty\Eigen\include\Eigen\src\Core\products\GeneralBlockPanelKernel.h:640:错误:无法使用 'const char [2] 找到字符串文字运算符 'operator""X' ', 'long long unsigned int' 参数 EIGEN_ASM_COMMENT("myend");

D:\Libraries\PCL_1.6.0\3rdParty\Eigen\include\Eigen\src\Core\products\GeneralBlockPanelKernel.h:644:错误:无法使用 'const char [2] 找到字符串文字运算符 'operator""X' ', 'long long unsigned int' 参数 EIGEN_ASM_COMMENT("mybegin4");

你能帮我解决这个问题吗?

标签: c++qtqmakepoint-cloud-library

解决方案


我建议使用CMake. 请参阅以下链接:

CMakeList.txt如下:

cmake_minimum_required(VERSION 2.8.11)

project(pcl_visualizer)

# init_qt: Let's do the CMake job for us
set(CMAKE_AUTOMOC ON) # For meta object compiler
set(CMAKE_AUTORCC ON) # Resource files
set(CMAKE_AUTOUIC ON) # UI files

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Find the QtWidgets library
find_package(Qt5 REQUIRED Widgets)

find_package(VTK REQUIRED)
find_package(PCL 1.7.1 REQUIRED)

# Fix a compilation bug under ubuntu 16.04 (Xenial)
list(REMOVE_ITEM PCL_LIBRARIES "vtkproj4")

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

set(project_SOURCES main.cpp pclviewer.cpp)

add_executable(${PROJECT_NAME} ${project_SOURCES})

target_link_libraries(${PROJECT_NAME} ${PCL_LIBRARIES} Qt5::Widgets)

希望它会帮助你。


推荐阅读