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

Martin Aumueller aumuell at reserv.at
Wed Apr 14 19:42:28 CEST 2010


On Wed, Apr 14, 2010 at 19:07, Paul Smith <phhs80 at gmail.com> wrote:
> 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?

I'd assume that you also have to pass it to the linker, not just the compiler:
QMAKE_LFLAGS *= -fopenmp

Martin

>
> Paul
> ----------------------------------------------
>
> #include <stdio.h>
> #include <cmath>
>
> int main()
> {
>
> #pragma omp for
>  for(int n=0; n<10; ++n)
>  {
>   printf(" %d", n);
>  }
>
> }
>
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-creator
>




More information about the Qt-creator-old mailing list