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.
Related
There is a project which is build via make command, where the Makefile is provided. Following are the Makefile contents:
TARGETT=gnulinux
OROPATH=/usr/local
CXXFLAGS=-I${OROPATH}/include -DOROCOS_TARGET=${TARGETT} -Wall
LDFLAGS=-L${OROPATH}/lib -Wl,-rpath ${OROPATH}/lib -lorocos-taskbrowser-${TARGETT} -lorocos-rtt-${TARGETT}
all: main
main.o: main.cpp
$(CXX) -c main.cpp $(CXXFLAGS)
AHRS.o: AHRS.cpp AHRS.h
$(CXX) -c AHRS.cpp $(CXXFLAGS)
main: main.o AHRS.o
$(CXX) -g -o main main.o AHRS.o $(CXXFLAGS) $(LDFLAGS)
clean:
rm -f main orocos.log .tb_history *.o
But I'm used to use QtCreator. I know that QtCreator constructs its own makefile from the project (.pro) file during build process. So, I think, relevant information must be copied from the Makefile contents (above) into a Qt Creator project file to allow QtCreator to generate the compatible makefile. Right?
Given the Makefile above, how should the .pro file look like?
And in the end of this process I'll be able to work from QtCreator.
Given the Makefile above, how should the .pro file look like?
Like this:
TEMPLATE = app
TARGET = AHRS # the desired filename of the executable goes here
OROPATH = /usr/local
INCLUDEPATH += $${OROPATH}/include
O_TARGET = gnulinux
DEFINES += OROCOS_TARGET=$${O_TARGET}
QMAKE_RPATHDIR += -L$${OROPATH}/lib
LIBS += -L$${OROPATH}/lib
LIBS += -lorocos-taskbrowser-$${O_TARGET} -lorocos-rtt-$${O_TARGET}
SOURCES += main.cpp AHRS.cpp
HEADERS += AHRS.h
Note that Qt Creator doesn't construct anything. qmake does. The project files are qmake projects, not Qt Creator projects. You don't need Qt Creator at all to build your project. You can do it from the command line using nothing but Qt and the compiler/binutils:
# assume that the source is in AHRS-source subfolder
mkdir AHRS
cd AHRS
/path/to/Qt/bin/qmake ../AHRS-source
make -j
# now we can run it
./AHRS
I want to build my resources with qmake as follows [Qt 5.5]:
imageTarget.target = images.rcc
imageTarget.depends = $$PWD/images.qrc
imageTarget.commands = rcc -binary -no-compress $$PWD/images.qrc -o $$OUT_PWD/images.rcc
QMAKE_EXTRA_TARGETS += imageTarget
When I run qmake for my .pro file, it generates the make rule for target images.rcc target as expected:
images.rcc: /path/to/images.qrc
rcc -binary -no-compress /path/to/images.qrc -o /output/path/to/images.rcc
So far so good.
However, what I would expect is that running qmake would also generate the output file images.rcc and it does not.
But when I go into the makefile directory and type in the command "make images.rcc", then the images.rcc is generated. Am I missing a point? How can I make target in the qmake step without the need of extra make?
With
QMAKE_EXTRA_TARGETS += imageTarget
you just define a new target - but it is not automatically built when running make.
Try to add
PRE_TARGETDEPS += images.rcc
This should automatically build a new images.rcc when running make if images.qrc has changed.
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...
I'm using Qt 5.1.1 and running qmake on windows.
I run qmake with the following command:
qmake.exe -spec win32-msvc2012 -tp vc project.pro
Somehow in my makefile it generates some weird relative paths:
INCPATH = -I"..\..\..\qt\qwt-6.1.0\src"
for example.
My includepaths in the .pro file are the following:
INCLUDEPATH += \
$$PWD \
$$QWTDIR \
what did I do wrong? (The compiler searches for ......\ which it isn't allowed to access for sure)
qwtdir is defined as:
QWTDIR = C:/qt/qwt-6.1.0/src
I resolved the error. Someone committed corrupted .pri file which didn't contain a proper line break after an include i.e.:
HEADERS += \
$$PWD/file1.h \ $$PWD/file2.h
Adding a proper line break solved the issue.
INCLUDEPATH += $$PWD is most likely unnecessary.
Your $$QWTDIR is relative, most likely - you'd need to relent and show it to us. Use $$absolute_path($${QWTDIR}).
You could also probably put the include paths all on one line. The trailing line continuation in the last line of INCLUDEPATH is wrong, you must remove it:
INCLUDEPATH += \
$$PWD \
$$QWTDIR
You are trying to build against the source tree of Qwt ( probably copying the project files of the Qwt examples ) instead of installing Qwt properly and building against the installed version using:
CONFIG += qwt
See http://qwt.sourceforge.net/qwtinstall.html
including the maya ( 3d application ) classes in qt program gives lot of errors..... i have added all required include paths and libs...the same problem persists ....
this is pro file for my qt project
TARGET = FileCon
TEMPLATE = app
SOURCES += main.cpp \
dialog.cpp
HEADERS += dialog.h \
ConvertFunction.h
FORMS += dialog.ui
LIBS += "C:/Program Files/Autodesk/Maya2008/lib" \
-lOpenMaya.lib \
-lFoundation.lib \
-lOpenMayalib
INCLUDEPATH += "C:/Program Files/Autodesk/Maya2008/include"
DEFINES = _BOOL \
WIN32 \
REQUIRE_IOSTREAM
///////////////////////////////////////////
How is it possible to use maya classes with qt.
Try something like this
LIBS += $$quote(-LC:/Program Files/Autodesk/Maya2008/lib) \
-lOpenMaya \
-lFoundation
qmake LIBS variable
If you are using QtCreator with the included compiler on Windows, it expects ".a" style libraries, rather than Visual Studio ".lib" style libraries.
You still haven't given enough infromation about eaxctly what you are doing. (How are you building, what compiler, etc.) or what is going wrong (exact error messages) to know for sure if that's the issue. But, if my crystal ball is working well today, I'd recommend checking the library format.