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:
- include the omp.h in your source like the following:
#include <omp .h>
- Then add the following lines to the .pro file in your project
QMAKE_CXXFLAGS += -fopenmp QMAKE_LFLAGS *= -fopenmp
- 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.
- Finally, extract the file somewhere on your disk.
- Now if you have a look, three folders should have been extracted, which are:
- Open up the Pre.built.2 folder
- Open up the lib directory
- 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.
- 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.
- 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.