[英]qt, library -like project, and include <>
In Qt, I want to have a separate library-like project (not .lib, simple .cpp/.h files, but in separate project). 在Qt中,我希望有一个单独的类似库的项目(不是.lib,简单的.cpp / .h文件,而是一个单独的项目)。 Lets call it "library". 让我们称之为“图书馆”。 Project which will include it call "test". 将包括它的项目称为“测试”。 To achieve this, in "library" project I create .pri file, instead of .pro. 为此,在“库”项目中创建.pri文件而不是.pro。 And from this moment I have the following file struct: 从这一刻起,我有了以下文件结构:
/library
library.pri
calc.h
calc.cpp
/test
test.pro
main.cpp
The containment of library.pri is the following: library.pri的内容如下:
SOURCES += calc.cpp
HEADERS += calc.h
test.pro: test.pro:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
#include(../library/library.pri)
SOURCES += main.cpp
Now I want to include calc.h . 现在,我想包含calc.h。 But I don't want to specify relative dir, ie: 但我不想指定相对目录,即:
#include "../library/calc.h"
, I want : #include <calc>
#include "../library/calc.h"
,我想要: #include <calc>
How to do that? 怎么做?
Put this into the library.pri
project include file: 将其放入library.pri
项目包含文件:
SOURCES += calc.cpp
HEADERS += calc.h
INCLUDEPATH += $$PWD # this is the extension!
This addition ensures that any project file including this project include file gets the include path right for that library folder, not only "test". 此添加操作确保包括该项目包含文件在内的所有项目文件都获得该库文件夹的包含路径,而不仅仅是“测试”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.