如何使用 qmake 将 pcl 库成功添加到 qt 项目中

How to add successfully pcl library to a qt project with qmake

本文关键字:添加 qt 项目 成功 何使用 qmake pcl      更新时间:2023-10-16

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

我试图将来自 pcl lib 的路径以及 pcl 使用的第三方库添加到 .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:错误:找不到字符串文字运算符"运算符"X",带有"const char [2]","long long unsigned int"参数 EIGEN_ASM_COMMENT("我的开始2");

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

D:\Libraries\PCL_1.6.0\3rdParty\Eigen\include\Eigen\src\Core\products\GeneralBlockPanelKernel.h:644:错误:找不到字符串文字运算符"运算符"X"与"const char [2]","long long unsigned int"参数 EIGEN_ASM_COMMENT("我的开始4");

你能帮我解决问题吗?

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

  • 这是PointCloudLibrary提供的两个例子,CMake:qt_colorize_cloud和qt_visualizer。
  • 这是Qt中配置的说明。

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)

希望对您有所帮助。