[Qt-creator] How to add -fopenmp to a project

Paul Smith phhs80 at gmail.com
Wed Apr 14 19:07:49 CEST 2010


On Wed, Apr 14, 2010 at 4:48 PM,  <erik.verbruggen at nokia.com> wrote:
>> How to add
>>
>> -fopenmp
>>
>> to g++ of a project?
>
> Assuming you are using qmake projects, you can do this by adding the line to your .pro file:
>
>   QMAKE_CXXFLAGS+=-fopenmp

Thanks, Erik. I did so, but still getting this error with the program below:

Running build steps for project parallel...
Configuration unchanged, skipping QMake step.
Starting: /usr/bin/make -w
make: Entering directory `/home/psmith/parallel'
g++ -Wl,-O1 -o parallel parallel.o -lQtGui -lQtCore -lpthread
parallel.o: In function `main':
/home/psmith/parallel/parallel.cpp:7: undefined reference to
`omp_get_num_threads'
/home/psmith/parallel/parallel.cpp:7: undefined reference to
`omp_get_thread_num'
parallel.o: In function `printf':
/home/psmith/parallel/parallel.cpp:7: undefined reference to `GOMP_barrier'
collect2: ld returned 1 exit status
make: *** [parallel] Error 1
make: Leaving directory `/home/psmith/parallel'
Exited with code 2.
Error while building project parallel
When executing build step 'Make'

Any ideas?

Paul
----------------------------------------------

#include <stdio.h>
#include <cmath>

int main()
{

#pragma omp for
 for(int n=0; n<10; ++n)
 {
   printf(" %d", n);
 }

}




More information about the Qt-creator-old mailing list