Qmake 和 Make 使用单独的文件夹来存放源文件和标头
我对这个愚蠢的问题快要疯了。
我有一棵这样的树:
src |--- sources |--- one.cpp |--- two.cpp |--- sources.pro |--- headers |--- one.h |--- two.hpp |--- headers.pro |--- src.pro
我尝试了一切方法让它在两个文件夹中都能看到,但不知何故我无法让它工作。我对 QMake 不太了解,但我认为这很容易。我错了。
所以实际上我最终以这种方式获得了 src.pro 文件:
QT += dbus
CONFIG += warn_on
DEFINES = QT_FATAL_WARNINGS QT_NO_DEBUG_OUTPUT
devel {
DEFINES -= QT_NO_DEBUG_OUTPUT
}
OBJECTS_DIR += build
MOC_DIR += build
TARGET = example
[...]
TEMPLATE = subdirs
SUBDIRS = sources \
headers
[...]
以及 resources.pro 和 headers.pro 以这种方式:
sources.pro
SOURCES = one.cpp \
two.cpp
headers.pro
HEADERS = one.h \
two.hpp
以及当然(不是)问题是它仍然没有看到所有的东西。 我也看了文档,但我发誓我不明白,哈哈
I'm going mad on this stupid problem.
I've a tree like this:
src |--- sources |--- one.cpp |--- two.cpp |--- sources.pro |--- headers |--- one.h |--- two.hpp |--- headers.pro |--- src.pro
I tried EVERYTHING to make it look in both the folders, but somehow I can't get it working. I don't know much about QMake, but I tought it was easy. And I was wrong.
So actually I ended up having the src.pro file in this way:
QT += dbus
CONFIG += warn_on
DEFINES = QT_FATAL_WARNINGS QT_NO_DEBUG_OUTPUT
devel {
DEFINES -= QT_NO_DEBUG_OUTPUT
}
OBJECTS_DIR += build
MOC_DIR += build
TARGET = example
[...]
TEMPLATE = subdirs
SUBDIRS = sources \
headers
[...]
And the sources.pro and headers.pro in this way:
sources.pro
SOURCES = one.cpp \
two.cpp
headers.pro
HEADERS = one.h \
two.hpp
And of course (not) the problem is that it still doesn't see the stuff all together.
I looked at the documentation too, but I swear I don't get it lol
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自从我不得不使用 qmake 以来已经有一段时间了(万岁 CMake!),但是你不能只设置
.pro
文件中的INCLUDEPATH
变量,即执行以下操作:然后只需将
SOURCES
var 中的条目指向sources
文件夹如下:我不清楚为什么要使用
TEMPLATE = subdirs
。对于你的情况来说似乎没有必要。难道你不能只使用TEMPLATE = app
(或TEMPLATE = lib
)并完成它吗?像这样的东西:It's been awhile since I've had to use qmake (long live CMake!), but can't you just set the
INCLUDEPATH
variable in your.pro
file, i.e., do something like:Then just point the entry in your
SOURCES
var at thesources
folder like so:It's not clear to me why you're using
TEMPLATE = subdirs
. It doesn't seem like it should be necessary in your case. Can't you just useTEMPLATE = app
(orTEMPLATE = lib
) and be done with it? Something like this: