Qmake incorrect output directory - qt

When I try to generate a makefile with qmake in a sub-directory, the makefile is generated in a wrong directory.
Here is my QmakeTest.pro, the main.cpp is a simple hello world code :
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
When I run qmake:
qmake -makefile -o build/makefile
qmake -makefile -o build/makefile
The first time, the folder build/ is created and the makefile is created in the right directory, the second time(and each time if build/ already exist), the makefile is generated in the folder build/build/ (a subfolder build inside the first one).
Why does qmake create a second subdirectory if the subdirectory build/ already exist ?
For info: qmake --version
QMake version 3.0
Using Qt version 5.3.0 in /usr/lib/x86_64-linux-gnu
Edit: The bug seems to be fixed with the QMake provided with qt 5.4.0

You can use
QMAKE_MAKEFILE += build/makefile
in your project file to create the makefile

Related

Makefile made by qmake only works on my pc

For a university project we made an OpenGL application which uses Qt for the GUI. When I use qmake -spec macx-g++ project.pro I can make a Makefile, and if I then do make it correctly makes the application. However, when I then send the complete folder to the other person in the project and he does make he gets the error
Makefile:209: warning: overriding commands for target `moc_window.cpp'
Makefile:203: warning: ignoring old commands for target `moc_window.cpp'
make: *** No rule to make target `/usr/lib64/qt-3.3/mkspecs/default/qmake.conf', needed by `Makefile'. Stop.
However, when in the same folder he does qmake; make it does work correctly. The problem is that when handing the code in we don't know if the professor has qmake available, so we would like it to work by only using make. Are we missing something that should be addded to have the Makefile made with qmake work, without having to do qmake again? Our .pro file is below.
TEMPLATE = app
TARGET = smoke
QT = core gui opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
SOURCES += \
fluids.cpp \
simulation.cpp \
visualization.cpp \
window.cpp \
myglwidget.cpp \
vector.cpp \
grid.cpp \
scalar.cpp
HEADERS += \
window.h \
myglwidget.h \
simulation.h \
vector.h \
grid.h \
visualization.h \
scalar.h
INCLUDEPATH += fftw-2.1.5/include /usr/local/include include
LIBS += -L"$$_PRO_FILE_PWD_/fftw-2.1.5/lib" -lrfftw -lfftw -framework OpenGL -framework GLUT -stdlib=libc++
QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11
FORMS += \
window.ui
The build directory is not portable. It is only ever meant to work on the system where you executed qmake, and for the particular Qt install that you ran qmake from. Recall that each Qt install has its own qmake, so e.g. if you have three Qt versions, each provides its own qmake that you must use to build a project using that version.
The project you ship should contain the .pro file, the sources, and whatever else the build calls for, like icon files, resources, etc.
The recipient, to build it, should:
Create a build folder.
cd into the build folder.
qmake /path/to/sources/project.pro && make -j
That's how you distribute and build Qt projects.
why does qmake not build the application directly?
Why do you not make your own shoes? The reasons are the same. Don't reinvent the wheel.
Of course, engineers sometimes have an itch to scratch. Enter Qt Build System (qbs). If your project's build is given as a .qbs file, then you do:
Create a build root folder.
cd into the build root folder.
qbs -f /path/to/sources/project.qbs - this builds the project.

How to put gstab+ option to mingw makefile generated by qmake

I am newby in Qt, and try to compile tutorial application with MinGW. The only problem, that I need to put -gstab+ option to gcc compiler instead of -g option that qmake generated by default.
Currently, I select debug configuration (it add CONFIG += debug to the qmake command-line).
I've tried to add CONFIG += gstab+ to the .pro file, but it does not work. qmake generates makefile.Debug file with -g option.
What do I make wrong? And how should it be?
I've found a solution here http://qt-project.org/forums/viewthread/2412
I've added the following lines to my .pro file:
QMAKE_CXXFLAGS_DEBUG += "-gstabs+"
QMAKE_CFLAGS_DEBUG += "-gstabs+"

Qt Creator: copy .exe output into a folder

I am sorry if the question was already asked but after some research I couldn't find an answer. I want to copy the .exe of a project into a folder automatically.
I am using Qt creator 5.0.1 MSCV2010 and it always makes two outputs: release and debug.
For example, I want the /release/project.exe to be in /release/exec/project.exe.
I saw I can copy file like .dll with in a .pro with:
INSTALLS =
But it only work with files which already exist, or the .exe is generated after the compilation. I think I can specify this into:
projects settings->Build compilation->step Make : jom.exe in C:\path\to\project-release
But I don't know what argument is needed,
Regards
On Windows you can use DLLDESTDIR variable which specifies where to copy the target dll or exe. Just add this to your .pro :
CONFIG(release, debug|release): DLLDESTDIR += $$PWD/../exec
On Linux you can use QMAKE_POST_LINK variable which contains the command to execute after linking the TARGET together. So it is like:
CONFIG(release, debug|release): QMAKE_POST_LINK += $$quote(cp project $$PWD/../exec)
Here project is the name of the target file which you provide by TARGET = project
These will copy the executable binary to a directory named exec one level upper than the program working directory. You can have your arbitrary path.
add a custom build step with the command an parameters
for windows (assuming you are doing this for the release build):
xcopy
Release\<target.exe> path\to\destination\file.exe /Y
%{buildDir}
This should work. I couldn't find any variable that points the target_path. So I defined it:
### to copy target file to build folder
CONFIG(debug, debug|release) {
TARGET_PATH = $$OUT_PWD/debug
}
CONFIG(release, debug|release) {
TARGET_PATH = $$OUT_PWD/release
}
win32: QMAKE_POST_LINK += copy /y "$$shell_path($$TARGET_PATH/app_name.exe)" "$$shell_path($$PWD/../build/)"
unix: QMAKE_POST_LINK += cp "$$shell_path($$TARGET_PATH/app_name)" "$$shell_path($$PWD/../build/)"

Qt portable project folder

so i m trying to setup a movable folder for a Qt project where I 'll have this structure and everything will be dependent ONLY with that content..
project\
script.dat "script to invoke qmake with just a click"
qmake.exe
moc.exe
mkspec\ "win32-msvc2010" copy
common\ "necessary by qmake" copy
project.pro
sources\
main.cpp
etc...
headers\
etc...
depedencies\
Qt\
include\
lib\
dll\
e.g.Boost\
include\
lib\
dll\
as can be seen i want a decent folder structure where the script will append the path to the dlls and set QMAKESPEC etc with respect to the %cd% (PWD) directory of the .pro file...
However the problem arises when i invoke qmake.exe
C:\Users\ardit\Desktop\test>qmake -v
QMake version 3.0
Using Qt version 5.2.1 in C:\build-essential\Qt\5.2.1\msvc2010_opengl\lib
and after that
qmake -tp vc
creates a project that has everything linked to my Qt installation and NOT the folder specified in the pro
visual studio additional include directories:
"include";".";"........\build-essential\Qt\5.2.1\msvc2010_opengl\include";"........\build-essential\Qt\5.2.1\msvc2010_opengl\include\QtGui";"........\build-essential\Qt\5.2.1\msvc2010_opengl\include\QtCore";"debug";........\build-essential\Qt\5.2.1\msvc2010_opengl\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories)
I havent put the Qt installation in the Path, but still the qmake.exe knows it somewhow (registry perhaps?)...
example .pro file where include\ has copy of Qt5\include\ , lib\ and dll\ as well
TARGET= test
SOURCES += main.cpp\
mainwindow.cpp \
glwindow.cpp
HEADERS += mainwindow.h \
glwindow.h
INCLUDEPATH=$${PWD}\include $$PWD
DEPENDPATH=$${PWD}\include $$PWD
LIBPATH=$${PWD}\lib
LIBS+=-L$$LIBPATH -lQt5Core -lQt5Gui -lQt5Widgets
Sidenote: I m new here so plz dont bash me...
any help appreciated...

Adding QtLua to a QtCreator project

Well i have a folder called libqtlua-1.4 in which i have the libqtlua.so, the qtlua executable, and in libqtlua-1.4/src/QtLua i have the headers.
How can i include it in a qtcreator project?
(I am running in ubuntu 11.10)
Any suggestion would be appreciated.
You have to specify the library in you project file (file with .pro extension) to qmake be able to see them when compile:
LIBS += -L/path/to/your/lib/libqtlua-1.4 -lqtlua
INCLUDEPATH += /path/to/your/lib/libqtlua-1.4/src/QtLua
References: LIBS, INCLUDEPATH.

Resources