问题描述
我有一个项目我正在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
文件记录在:
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 ,< 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中添加包含路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!