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

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

问题描述

我有一个项目我正在Qt创建者中工作,需要第三方库。我想将标题添加到项目的包含路径中。我该怎么办?

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?

推荐答案

如果您使用的是qmake,标准的Qt构建系统,只需添加一行到 .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.

As 在Qt Creator手册中解释< your path> 必须是绝对路径,但您可以使用来避免 .pro 文件中的OS,主机或用户特定条目$$ 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天全站免登陆