Yassine Zaroui
Yassine Zaroui

Reputation: 403

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.

Upvotes: 4

Views: 2206

Answers (2)

user3610976
user3610976

Reputation: 23

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

Upvotes: 0

Yassine Zaroui
Yassine Zaroui

Reputation: 403

I finally got all the required elements to get it compiled with openmp from Qt Creator:

  1. Add #include <omp.h> to the source, which is not required if you compile with the command line mentioned above.
  2. 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
  3. 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.

Upvotes: 7

Related Questions