加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 程序设计 > 正文

QtCreator的中如何使用第三方依赖库

发布时间:2020-05-22 15:10:01 所属栏目:程序设计 来源:互联网
导读:之前项目里使用其它的第三方库都是leader或同事给配置好的,从没操心这回事,真是惭愧,。今天同学给我发来一个工程,需用使用到Qt库和Qwt库,用QtCreator打开编译,提示找不到Qwt库里的头文件,于是试着配置一下,居然折腾了许久还没运行起来。后来看了一下

之前项目里使用其它的第三方库都是leader或同事给配置好的,从没操心这回事,真是惭愧,。今天同学给我发来一个工程,需用使用到Qt库和Qwt库,用QtCreator打开编译,提示找不到Qwt库里的头文件,于是试着配置一下,居然折腾了许久还没运行起来。后来看了一下Qt的qmake文档,才得以搞定。qmake 的说明文档里有关于声明使用其它库的说明:

Declaring Other Libraries

If you are using other libraries in your project in addition to those supplied with Qt,you need to specify them in your project file.

The paths thatqmakesearches for libraries and the specific libraries to link against can be added to the list of values in theLIBSvariable. The paths to the libraries themselves can be given,or the familiar Unix-style notation for specifying libraries and paths can be used if preferred.

For example,the following lines show how a library can be specified:

 LIBS += -L/usr/local/lib -lmath

The paths containing header files can also be specified in a similar way using theINCLUDEPATHvariable.

For example,it is possible to add several paths to be searched for header files:

 INCLUDEPATH = c:/msdev/include d:/stl/include

如果电脑上已经安装了Qt和Qwt的环境,那么对于一个需要使用Qwt的程序来说,只需要在其工程文件中添加如下配置:

(假设你的Qwt安装目录为 C:/Qwt-6.0.1 )

1)在LIBS变量后面添加链接这个库的路径(例如-LC:/Qwt-6.0.1/lib)和名称(例如 -lqwt,也可以用 qtAddLibrary(qwt) 添加动态库)

2)在INCLUDEPATHvariable.后面添加这个引用该库所需要的头文件(例如 C:/Qwt-6.0.1/include)

#include( $${PWD}/../examples.pri )
#include( ../3rdparty/qwt/qwtplot.pri )
#include( C:/Qwt-6.0.1/features/qwtconfig.pri )
INCLUDEPATH += C:/Qwt-6.0.1/include #必须有
#DEPENDPATH  += C:/Qwt-6.0.1/lib
#LIBS += -L/usr/local/lib -lmath
LIBS      += -LC:/Qwt-6.0.1/lib -lqwt #必须有 否则报错 :-1: error: cannot find -lqwt
#qtAddLibrary(qwt) #必须有

#CONFIG += qwt

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读