[英]Qt qmake and DISTFILES
So I am learning to program in OpenGL 3.3 and I am using qtcreator as my IDE with qmake as the compiler. 因此,我正在学习在OpenGL 3.3中进行编程,并使用qtcreator作为我的IDE,并使用qmake作为编译器。 Everything is fine except I have to read 2 files (fragmentshader.frag and vertexshader.vert) using ifstream.
一切都很好,除了我必须使用ifstream读取2个文件(fragmentshader.frag和vertexshader.vert)。 I have included those 2 files in the ".pro" like this:
我在“ .pro”中包含了这两个文件,如下所示:
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp \
shaders.cpp
LIBS += -lGLEW -lglfw -lGL -lX11 -lpthread -lXrandr -lXi
DISTFILES += \
vertexshader.vert \
fragmentshader.frag
HEADERS += \
shaders.h
and in the code I try to directly read "vertexshader.vert" and "fragmentshader.frag". 在代码中,我尝试直接读取“ vertexshader.vert”和“ fragmentshader.frag”。
My question is: How do I include these files in my application without having to specify an absolute path? 我的问题是:如何在不指定绝对路径的情况下将这些文件包含在我的应用程序中?
I had the same problem, it comes from the fact Qt is running files from another directory (by default from the build one). 我有同样的问题,这是由于Qt正在从另一个目录(默认情况下是从构建目录)运行文件。
So you have two options: 因此,您有两种选择:
%{sourceDir}
. %{sourceDir}
。 .
.
or leave it blank. Choose the one you prefer the most, hope it helps. 选择最喜欢的一种,希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.