Multicore compilation with Qt 5.1 and jom on Windows 7 failed - windows

I have installed Qt 5.1.1 with MinGW 4.8 and QtCreator through Qt Online installer.
I launched Qt creator and made new project (Qt application Desktop) with MainWindow class based on QMainWindow (default). It works fine and popped up a mainwindow after compilation.
However, when I used C:\Qt\Qt5.1.1\Tools\QtCreator\bin\jom.exe instead of C:\Qt\Qt5.1.1\Tools\mingw48_32\bin\mingw32-make.exe , I got some output like below.
jom 1.0.13 - empower your cores
C:\Qt\Qt5.1.1\Tools\QtCreator\bin\jom.exe -f Makefile.Release
g++ -c -pipe -fno-keep-inline-dllexport -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I../foobar -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include' -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtWidgets' -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtGui' -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtCore' -I'release' -I'.' -I'.' -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/mkspecs/win32-g++' -o release/main.o ../foobar/main.cpp
In file included from ../foobar/main.cpp:1:0:
../foobar/mainwindow.h:4:23: fatal error: QMainWindow: No such file or directory
#include <QMainWindow>
^
compilation terminated.
jom: D:\work\build-foobar-Desktop_Qt_5_1_1_MinGW_32bit-Release\Makefile.Release [release\main.o] Error 1
jom: D:\work\build-foobar-Desktop_Qt_5_1_1_MinGW_32bit-Release\Makefile [release] Error 2
15:17:38: Process "C:\Qt\Qt5.1.1\Tools\QtCreator\bin\jom.exe" stopped with code 2
Error while building/deploying project foobar (kit: Desktop Qt 5.1.1 MinGW 32bit)
During step 'Make'
15:17:38: Elapsed time: 00:00.
My .pro is like this.
#-------------------------------------------------
#
# Project created by QtCreator 2013-09-08T15:16:13
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = foobar
TEMPLATE = app
SOURCES += main.cpp\ mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
I think the line in .pro greaterThan(QT_MAJOR_VERSION, 4): QT += widgets and in the output during compilation -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtWidgets' looks fine, but failed.
How can I compile with Qt 5.1 and jom on Windows 7 (32 bit)?
Thanks in advance.

Jom is a replacement of nmake and not MinGW's make.
nmake is the Visual Studio command line tool used to compile makefiles. Unfortunately that tool is using only one core (Parallel builds are handled inside Visual Studio either directly or using MSBuild, I'm not really sure). That being said, Jörg Bornemann wrote a tool called jom that sort of adds the -j command to nmake. It will allow you to compile your code using the Visual C++ compiler across different threads.
MinGW on the other end contains (amongst other things) a port of the GNU GCC compiler for Windows. Being a port, not everything that is possible to do with GCC is possible with MinGW and I guess that -jN is one of these. However, MinGW do support the option -j that will spawn as many processes as it can (beware that if you use this option, you may not be able to use your computer whilst compiling).
In your case, you probably want to use MinGW as your Qt version is compiled with it. If you want to use Visual Studio, you will have to install it but also either:
recompile Qt (and all other library dependencies) or
download the binary corresponding to the Visual Studio version you just installed.
Using jom should just work with QtCreator once this is done.

In my case I fixed this error by overriding system environment PATH in project settings by adding only bin path to qt, mingw and qtcreator: "E:\Qt\4.8.1\bin;E:\qt\mingw-4.4.0\bin;E:\Qt\qtcreator-4.0.0\bin" and after Run qmake and Rebuild

Related

How to select the target platform in clang?

Currently, I am using the command:
clang++ -o hello.exe hello.cpp
Is there any way to set the target platform, for example if I wanted to build targeting x86 or ARM on my x64 computer. In visual studio, you can easily set this under configurations. I am using clang front end and LLVM back end.

C++11 in Qt5 / QtCreator 3.0.1 on OSX

Just downloaded and installed Qt5 on OSX 10.9.2.
When trying to compile some C++11 code using the clang run kit, I get a failure when I try to include cstdint;
fatal error: 'cstdint' file not found
After a lot of googling, it seems that c++11 is not 'enabled' by default which triggers this error. It further seems that the way to enable c++11 has changed in Qt5. It should be as simple as adding CONFIG+=c++11 in "Projects -> Build & Run -> Build Steps -> Additional arguments" if I understand it correctly.
However this makes no difference whatsoever.
So; anyone knows how to enable c++11 using QtCreator with the clang kit?
About QtCreator gives me the following information:
QtCreator 3.0.1
Based on Qt 5.2.1 (Clang 5.0 (Apple), 64 bit)
The compiler output is as follows:
14:25:23: Running steps for project shelly...
14:25:23: Starting: "/Users/m/Qt5.2.1/5.2.1/clang_64/bin/qmake" /Volumes/files/Programmering/shelly/shelly.pro -r -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+=declarative_debug CONFIG+=qml_debug CONFIG+=c++11
14:25:23: The process "/Users/m/Qt5.2.1/5.2.1/clang_64/bin/qmake" exited normally.
14:25:23: Starting: "/usr/bin/make"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -c -pipe -g -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.7 -Wall -W -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/Users/m/Qt5.2.1/5.2.1/clang_64/mkspecs/macx-clang -I../shelly -I/Users/m/Qt5.2.1/5.2.1/clang_64/lib/QtOpenGL.framework/Versions/5/Headers -I/Users/m/Qt5.2.1/5.2.1/clang_64/lib/QtWidgets.framework/Versions/5/Headers -I/Users/m/Qt5.2.1/5.2.1/clang_64/lib/QtGui.framework/Versions/5/Headers -I/Users/m/Qt5.2.1/5.2.1/clang_64/lib/QtCore.framework/Versions/5/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/Users/m/Qt5.2.1/5.2.1/clang_64/lib -o datainterval.o ../shelly/core/datainterval.c++
In file included from ../shelly/core/datainterval.c++:5:
In file included from ../shelly/core/datainterval.h++:9:
../shelly/core/datatime.h++:9:10: fatal error: 'cstdint' file not found
#include <cstdint> // GPL w/runtime exception
^
1 error generated.
make: *** [datainterval.o] Error 1
14:25:24: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project shelly (kit: Desktop Qt 5.2.1 clang 64bit)
When executing step 'Make'
14:25:24: Elapsed time: 00:01.
Update:
Have made an 'minimal recreate' of my problem;
Create a new project, a “Qt Widgets Application”.
Leave everything at its defaults except for the path.
In the created file mainwindow.c++, add the cstdint include statement:
Try to build it (it fails as above)
Add in “Projects” -> “Build & Run” -> “Build Steps” -> “Additional arguments”
CONFIG+=c++11
The “Effective qmake call” line then reads
qmake /Users/m/Documents/ProgrammeringOSX/testC11/testC11.pro -r -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+=declarative_debug CONFIG+=qml_debug CONFIG+=c++11
…and the error is still there.
:(
I have the same setup as you, and have used c++11 features after updating the project .pro file with the following line:
CONFIG += c++11
However, I think your solution should accomplish the same thing, so it may be an external configuration issue. I wasn't able to reproduce the error when I included the header file.
Ok,
I seem to have “fixed” it… I got to the point that I was randomly changing parameters just to see what effect it had and all of a sudden this did it:
QMAKE_MACOSX_DEPLOYMENT_TARGET=10.9
(doesn’t matter if I set it in the .pro file or in the GUI)
If I added CONFIG+=c++11, the target was set to 10.7, without it 10.6, so this forces it to 10.9 (tried 10.8 as well, but nope; 10.9 it is).
A funny thing is that I do not need to add CONFIG+=c++11 in the “minimum recreation” version… I guess I will get to that point if I actually add any C++11 code. But baby steps, baby steps!
Another funny thing is that when I changed the target to 10.9, THEN my bogus QMAKE_CXXFLAGS parameters were added and the clang call failed (I guess it heeded my ‘pleaseFailNow’ parameter).
Thank you for your help!
Cheers
/ Daniel

Qt5, Visual Studio 2012 Express and OpenMp. How to?

I am trying to compile http://www.kevinbeason.com/smallpt/ raytracer using Qt5 and Visual Studio 2012 compiler.
It works Okay but when I try to use openmp by adding
QMAKE_CXXFLAGS += -fopenmp
LIBS += -fopenmp
to project.pro
, Qt says that /fopenmp is not recognized and ignored.
When I compile using VS command
cl /c /O2 /EHsc /openmp main.cpp
it works and I get a program 3 times faster then the one compiled from Qt.
How to make Qt recognize openmp and how to enable the other optimizations in the command line?
Thanks in advance.
I finally got all the required elements to get it compiled with openmp from Qt Creator:
Add #include <omp.h> to the source, which is not required if you compile with
the command line mentioned above.
Add QMAKE_CXXFLAGS += -openmp to the project file. It wont work
with -fopenmp. No need for any openmp lib like I did ( LIBS += -openmp ) neither for QMAKE_LFLAGS += -openmp
Compile as release. With debug it has no impact on performance.
The other optimization options are already configured in mkspecs\win32-msvc2012\
qmake.conf
Hope this helps someone else.
I want to run Qt project with openmp. I have followed the above steps, I could build the project, but execution time is increasing instead of reducing.
Here is the configuration I used
CONFIG += console c++11
CONFIG -= app_bundle
#CONFIG -= qt
QMAKE_CXXFLAGS+= -openmp

Generated .pro file from visual studio Qt addin adds unnecessary openGL libraries?

I've created a basic app in visual studio with Qt and an openGL widget. I export a .pro file from the addin so that I can compile in Linux.
I get the message:
/usr/bin/ld: cannot find -lopengl32
/usr/bin/ld: cannot find -lglu32
... when running make.
The issue goes away and the program compiles fine if I remove:
LIBS += -lopengl32 \
-lglu32
... from the generated .pro file.
I understand the "export .pro" feature is not flawless, but is this the correct way to fix this problem?
I don't quite remember the exact name of the OpenGL library on Linux, but it's not opengl32. Rather libopengl. So it's perfectly normal.
This will make you link with opengl32.lib on windows only:
win32 : LIBS += -lopengl32 -lglu32
and if needed, this will make you link with libopengl on Linux :
unix : LIBS += -lopengl -lglu
For the macx platform scope, I guess there is additional work to link with the OpenGL Framework.

QT 4.5 - How do I enable LTCG in VS2005 when linking to QT libraries?

While attempting to link with QT 4.5 release, I run into this error message
fatal error C1047: The object or
library file
'c:\qt\2009.02\qt\lib\qtmain.lib' was
created with an older compiler than
other objects; rebuild old objects and
libraries
I have been using the same compiler for my current projects to compile QT 4.5 (VS 2005, though I am not sure if I compile it with VS2005 SP1 or not, but I am using SP1 now). The problem only rears its head when another library I am compiling with has GL enabled (which switched to LTCG automatically by VS2005). I only could get the build to work if I disable all optimization in all other libraries (which prevent LTCG from being enabled)
Is there a way to get QT 4.5 to work with LTCG release build process? If I have to recompile, what flags need I to set for nmake?
By the way, the project is created with QT 4.5 Visual Studio Add-in, and for the release build it has GL turned off automatically.
I just ran into a similar problem while trying to build the examples in Qwt and did the same thing you did -- I removed the -GL switch from all of the Makefiles (Makefile.Release). A bit of a pain but all the examples now run.
From the comments in this thread it looks like Qt 4.5.0 now uses the /GL and /LTCG flags.
Update 2010-01-14 New method to just get rid of the whole -GL / -LTCG issue:
Edit C:\Qt\4.5.1\mkspecs\win32-msvc2008\qmake.conf (or the one that corresponds to your version of MSVC) and change the lines
QMAKE_CFLAGS_RELEASE = -O2 -MD -GL
to
QMAKE_CFLAGS_RELEASE = -O2 -MD
and
QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO /LTCG
to
QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO
Now any Makefile that is created will not have these flags present.
Update 2010-03-22 It appears Qt 4.6.1 has fixed the original issue. Give it a spin.
On a closer look at the complie options for QT 4.5, there is a flag to enable LTCG. It is disabled by default.

Resources