Search code examples
qtmingwopenmpqmakeopennn

Compile OpenNN with Qt in Windows and Mingw 5.30


Im trying to compile the openNN Project with Qt. Im using qt precompiled mingw32 for windows and the last opennn 3.1 projekt sources. Opennn comes already with .pro Project files for direct use with qt creator/qmake.

However when i try to compile it i get the following errors:

   D:/Projekte/opennn_build/opennn/release\libopennn.a(testing_analysis.o):testing_analysis.cpp:(.text+0xfc): undefined reference to `omp_get_num_threads'
D:/Projekte/opennn_build/opennn/release\libopennn.a(testing_analysis.o):testing_analysis.cpp:(.text+0x103): undefined reference to `omp_get_thread_num'
D:/Projekte/opennn_build/opennn/release\libopennn.a(testing_analysis.o):testing_analysis.cpp:(.text+0x22f): undefined reference to `GOMP_loop_dynamic_start'
D:/Projekte/opennn_build/opennn/release\libopennn.a(testing_analysis.o):testing_analysis.cpp:(.text+0x3d3): undefined reference to `GOMP_loop_dynamic_next'
D:/Projekte/opennn_build/opennn/release\libopennn.a(testing_analysis.o):testing_analysis.cpp:(.text+0x3e0): undefined reference to `GOMP_loop_end_nowait'
D:/Projekte/opennn_build/opennn/release\libopennn.a(testing_analysis.o):testing_analysis.cpp:(.text+0x64b): undefined reference to `GOMP_loop_dynamic_start'

it seems to be connected to openmp, however the *.pro files of opennn already contain the always suggested lines:

QMAKE_CXXFLAGS+= -fopenmp
QMAKE_LFLAGS +=  -fopenmp

trying to add the following didnt help either

LIBS+= -fopenmp

i need to make it work with qt, because i wanted to add it to an already existing qt project later.


Solution

  • solution: edit in openn/tests/tests.pro and the "exampletitle".pro file of each example in openn/examples/"exampletitle"/

    change:

    win32-g++{
    QMAKE_LFLAGS += -static-libgcc
    QMAKE_LFLAGS += -static-libstdc++
    QMAKE_LFLAGS += -static
    }
    

    to

    win32-g++{
    QMAKE_LFLAGS += -static-libgcc
    QMAKE_LFLAGS += -static-libstdc++
    QMAKE_LFLAGS += -static
    LIBS += -fopenmp
    }