c++qtopenmplinker-warning

linker ignores /openmp in qtcreator on windows


when I try to compile the openmp cpp file from this website, I got a link warning saying that the openmp flag is ignored.

LNK4044:unrecognized option '/openmp'; ignored

I have already added these code to the pro. file

QMAKE_CXXFLAGS+= -openmp
QMAKE_LFLAGS +=  -openmp

or

QMAKE_CXXFLAGS += -fopenmp
LIBS += -fopenmp

as suggeted by some other stack overflow questions.But that does not solve the problem. Can any one help me to solve this problem? I am using the qt creator 3.1.2 with msvc2013 compiler on windows 7.


Solution

  • MSVC's linker does not need or accept the /openmp option. You only need that option for GCC (in which case the option is -fopenmp). Although I use CMake now with QtCreator instead of qmake here is a sample from the last qmake file I use.

    msvc {
      QMAKE_CXXFLAGS += -openmp -arch:AVX -D "_CRT_SECURE_NO_WARNINGS"
      QMAKE_CXXFLAGS_RELEASE *= -O2
    }
    
    gcc {
      QMAKE_CXXFLAGS += -fopenmp -mavx -fabi-version=0 -ffast-math
      QMAKE_LFLAGS += -fopenmp
      QMAKE_CXXFLAGS_RELEASE *= -O3
    }