如何在 Qt Creator 中添加包含路径? [英] How to add include path in Qt Creator?

查看:43
本文介绍了如何在 Qt Creator 中添加包含路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Qt Creator 中有一个需要第三方库的项目.我想将标题添加到项目的包含路径中.我该怎么做?

I have a project I'm working on in Qt creator that requires a third-party library. I want to add the headers to the include path for the project. How do I do this?

推荐答案

如果您使用的是标准 Qt 构建系统 qmake,只需在 .pro 文件中添加一行,如qmake 变量参考:

If you are using qmake, the standard Qt build system, just add a line to the .pro file as documented in the qmake Variable Reference:

INCLUDEPATH += <your path>

如果您使用自己的构建系统,您可以通过选择导入基于 Makefile 的项目"来创建项目.这将在您的项目目录中创建一些文件,包括名为 .includes 的文件.在该文件中,只需列出要包含的路径,每行一个.实际上,所有这些都是告诉 Qt Creator 在哪里查找文件以进行自动完成索引.您自己的构建系统必须以自己的方式处理包含路径.

If you are using your own build system, you create a project by selecting "Import of Makefile-based project". This will create some files in your project directory including a file named <your project name>.includes. In that file, simply list the paths you want to include, one per line. Really all this does is tell Qt Creator where to look for files to index for auto completion. Your own build system will have to handle the include paths in its own way.

正如 在Qt Creator 手册 必须是绝对路径,但您可以避免在 .pro 文件通过使用 $$PWD 引用包含您的 .pro 文件的文件夹,例如

As explained in the Qt Creator Manual, <your path> must be an absolute path, but you can avoid OS-, host- or user-specific entries in your .pro file by using $$PWD which refers to the folder that contains your .pro file, e.g.

INCLUDEPATH += $$PWD/code/include

这篇关于如何在 Qt Creator 中添加包含路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆