How to use OpenMP in QTcreator within Windows (when using MINGW compiler)

For those of you who have been spending hours on google trying to get these two to work together, then this article will show you how to do just that.

First of all, I’m assuming that you’re using the MINGW compiler.

The following short list details what to do:

  1. include the omp.h in your source like the following:
#include <omp .h>
  1. Then add the following lines to the .pro file in your project
QMAKE_CXXFLAGS += -fopenmp
QMAKE_LFLAGS *= -fopenmp
  1. Then go to the following link: ftp://sourceware.org/pub/pthreads-win32 , and download one of the self extracting files named “pthread-w32-v-v-v-release.exe” where v-v-v stands for the version, any one of them will do.
  2. Finally, extract the file somewhere on your disk.
  3. Now if you have a look, three folders should have been extracted, which are:
    1. Pre.built.2
    2. pthreads.2
    3. QueueUserAPCEx
  4. Open up the Pre.built.2 folder
  5. Open up the lib directory
  6. Copy the “pthreadGC2.dll” file from that directory into the windows system32 directory. (if in windows 64 bit, copy the file into the windows SYSWOW64 directory)

The project should now work flawlessly.

Troubleshooting

  1. If you’re getting the infamous “exited with code -1073741515” output, then it’s because the program is not finding the pthreadGC2.dll library.  Copy it into the correct directory or create a PATH to it.
  2. If you’re getting the “collect2: Id returned 1 exit status”, it’s because it’s not linking, make sure you add the above lines into the .pro file of your project.

About Vincenzo Barbato

Known to his friends as Enzo, he's an outside-the-box engineer/researcher whose interests and expertise span many fields, including controls systems, multi-physics simulations, mechatronics, oil technologies, data analysis and machine vision just to name a few.

Refusing to grow up, he's on a continuous journey to develop simple and creative solutions that have the power of disrupting industries by optimizing systems and processes.

Married to a beautiful wife, with two beautiful daughters and two identical twin boys, his home is a never ending chaotic fountain of inspiration.

His outlook on life:

"Never blindly accept what you're told, listen, but then question, with curiosity, creativity and collaboration we can change the world"

About Enzo

Known to his friends as Enzo, he's an outside-the-box engineer/researcher whose interests and expertise span many fields, including controls systems, multi-physics simulations, mechatronics, oil technologies, data analysis and machine vision just to name a few. Refusing to grow up, he's on a continuous journey to develop simple and creative solutions that have the power of disrupting industries by optimizing systems and processes. Married to a beautiful wife, with two beautiful daughters and two identical twin boys, his home is a never ending chaotic fountain of inspiration. His outlook on life: "Never blindly accept what you're told, listen, but then question, with curiosity, creativity and collaboration we can change the world"

One Comment

  1. bonjour
    great share.
    I think the most stable cccam servers are those from Fishbone cccam
    I would like to see more posts like this
    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *