【问题标题】:Linking library in QTCreator with QMake?将 QTCreator 中的库与 QMake 链接?
【发布时间】:2012-11-13 07:43:50
【问题描述】:

我是 QTCreator 的一个相对较新的用户,我之前使用过标准库和 QT 库,但这是我尝试的第一个项目 添加一个外部库,我遇到了问题。

我正在尝试使用Point Cloud Library,据我所知,我在usr/lib 中正确安装了它,但是当我尝试执行this 简单教程时,包含不起作用:

#include <boost/thread/thread.hpp>
#include <pcl/common/common_headers.h>
#include <pcl/features/normal_3d.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/console/parse.h>

给我这个错误:

/home/george/Documents/QT/EditorPCL-build-desktop-Qt_4_8_1_in_PATH__System__Release/../EditorPCL/editor.cpp:7: error: pcl/common/common_headers.h: No such file or directory

现在我通过 GUI 添加了库,所以在语法上我认为 QMake 文件是正确的,但我不知道有什么问题。

这是 QMake 文件的相关部分:

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../usr/lib/      -lpcl_visualization
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../usr/lib/   -lpcl_visualizationd
else:symbian: LIBS += -lpcl_visualization
else:unix: LIBS += -L$$PWD/../../../../../usr/lib/ -lpcl_visualization

INCLUDEPATH += $$PWD/../../../../../usr/lib
DEPENDPATH += $$PWD/../../../../../usr/lib

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../usr/lib/release/ -lpcl_common
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../usr/lib/debug/ -lpcl_common
else:symbian: LIBS += -lpcl_common
else:unix: LIBS += -L$$PWD/../../../../../usr/lib/ -lpcl_common

INCLUDEPATH += $$PWD/../../../../../usr/lib
DEPENDPATH += $$PWD/../../../../../usr/lib

 win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../usr/lib/release/ -lpcl_apps
 else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../usr/lib/debug/ -lpcl_apps
 else:symbian: LIBS += -lpcl_apps
 else:unix: LIBS += -L$$PWD/../../../../../usr/lib/ -lpcl_apps

 INCLUDEPATH += $$PWD/../../../../../usr/lib
 DEPENDPATH += $$PWD/../../../../../usr/lib 

【问题讨论】:

    标签: qt-creator qmake


    【解决方案1】:

    编译器在尝试查找标头时抛出了您的错误。

    ... error: pcl/common/common_headers.h: No such file or directory
    

    这告诉我它没有找到正确的包含路径。查看您的 QMake 文件,我看到您正在将包含路径设置为

    INCLUDEPATH += $$PWD/../../../../../usr/lib
    

    在大多数 Linux/Unix(甚至 Windows)系统上,包含不在子目录 lib 中,而是在子目录 include 中。

    此外,我不喜欢您指定 LIBPATH 和 INCLUDEPATH 的方式。如果 PWD 和文件的安装位置都从不移动,它们将起作用。一个更好的建议(至少对于 Unix/Linux)是使用 pkg-config 实用程序。您可能想阅读文章Using pkg-config with Qmake 看看它是否会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-17
      • 1970-01-01
      • 2011-02-24
      • 2011-01-18
      • 2010-11-10
      相关资源
      最近更新 更多