Qt portable project folder - qt

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...

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.

Qt creator: include path for external lib not found

I'm trying to add net-snmp lib to my project using win7 + cygwin:
Project file seems to contain valid lib and path entries:
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/C:/usr/lib/
-lnetsnmp else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/C:/usr/lib/ -lnetsnmpd
INCLUDEPATH += $$PWD/C:/usr/include DEPENDPATH += $$PWD/C:/usr/include
But I can't build the project, because include file is not found, also it exists under given directory physically (c:/usr/include/net-snmp/net-snmp-config.h)
../snmptest1221313123/main.cpp:1:38: fatal error: net-snmp/net-snmp-config.h: No such file or directory
#include
I've read all "add external lib" topics, but it doesn't help to solve this.
Re-running qmake, re-opening Qt creator, or running qmake -r from terminal doesn't help neither.
Remove $$PWD/ (both from include and libs) and try again: run qmake and rebuild.

Qmake incorrect output directory

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

How do I stop Qt Creator placing my executable in a "debug" subdirectory?

I'm building a project in Qt Creator, and while I don't care where the intermediate .obj files go it's important that the final executable be put in (and run from) a particular directory where the many dependency DLLs etc. are to be found.
So, in Qt Creator, I select the 'Shadow Build' option and specify the path to this directory.
What I always find, however, is that instead of being put into this directory, the final executable is always placed into
the_Directory_I_Actually_Want/debug
... which is no use to me because, when I then try to run or debug the program from within Qt Creator, it won't start because the DLLs that it depends on are all in the_Directory_I_Actually_Want and not in the /debug subdirectory.
I've tried setting DESTDIR within my .pro file to the the_Directory_I_Actually_Want, and I've tried setting TARGET within my .pro file to the_Directory_I_Actually_Want/projectName, and I've tried faddling around with the various options that are part of the 'kit' configuration, and nothing seems to let me have any control over this.
Is there a way of doing this, or am I going to have to change the rest of my build system around just for Qt Creator's benefit?
Three years later...
Just use:
CONFIG -= \
copy_dir_files \
debug_and_release \
debug_and_release_target
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.

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