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

Paul Smith phhs80 at gmail.com
Wed Apr 14 19:47:06 CEST 2010


On Wed, Apr 14, 2010 at 6:42 PM, Martin Aumueller <aumuell at reserv.at> 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

Thanks, Martin. That is it!

Paul




More information about the Qt-creator-old mailing list