OpenMP - Linker Errors for MathGL
Oct 20, 2014 at 9:43am UTC
I'm getting a bunch of linker errors when compiling MathGL with it's dependency OpenMP.
From what the below says, I need to add linker flags to the build process. I'm using Cmake 2.8.9 (which is the minimum for MathGL) and MinGW 4.7.1. Operating System Windows XP.
I copied and pasted a section from another forum which seems to provide the solution to this but I don't know where to put these flags. I'm compiling using a Makefile via command line. The below is for something else but it's the same problem.
OpenMP requires a runtime library (called libgomp in case of gcc), which must be linked into the created executable. It is therefore not sufficient to add the OpenMP flags to the compilation flags, they must also be added to the link flags:
set_target_properties(<target_name> LINK_FLAGS "${OpenMP_CXX_FLAGS}")
I've pasted the error below. There's allot but I think it will explain the extent of the problem.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
c:\mathgl-2.3>mingw32-make -f Makefile
mingw32-make[1]: Entering directory 'c:/mathgl-2.3'
"C:\Program Files\CMake 2.8\bin\cmake.exe" -HC:\mathgl-2.3 -BC:\mathgl-2.3 --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Program Files\CMake 2.8\bin\cmake.exe" -E cmake_progress_start C:\mathgl-2.3\CMakeFiles C:\mathgl-2.3\CMakeFiles\progress.marks
mingw32-make -f CMakeFiles\Makefile2 all
mingw32-make[2]: Entering directory 'c:/mathgl-2.3'
mingw32-make -f src\CMakeFiles\mgl.dir\build.make src/CMakeFiles/mgl.dir/depend
mingw32-make[3]: Entering directory 'c:/mathgl-2.3'
"C:\Program Files\CMake 2.8\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\mathgl-2.3 C:\mathgl-2.3\src C:\mathgl-2.3 C:\mathgl-2.3\src C:\mathgl-2.3\src\CMakeFiles\mgl.dir\DependInfo.cmake --co
lor=
mingw32-make[3]: Leaving directory 'c:/mathgl-2.3'
mingw32-make -f src\CMakeFiles\mgl.dir\build.make src/CMakeFiles/mgl.dir/build
mingw32-make[3]: Entering directory 'c:/mathgl-2.3'
Linking CXX shared library libmgl.dll
cd /d C:\mathgl-2.3\src && "C:\Program Files\CMake 2.8\bin\cmake.exe" -E cmake_link_script CMakeFiles\mgl.dir\link.txt --verbose=1
"C:\Program Files\CMake 2.8\bin\cmake.exe" -E remove -f CMakeFiles\mgl.dir/objects.a
C:\CodeBlocks\MinGW\bin\ar.exe cr CMakeFiles\mgl.dir/objects.a @CMakeFiles\mgl.dir\objects1.rsp
C:\CodeBlocks\MinGW\bin\g++.exe -shared -o libmgl.dll -Wl,--out-implib,libmgl.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -Wl,--whole-archive CMakeFiles\mgl.dir/objects.a -Wl,--no-wh
ole-archive -lglu32 -lopengl32 C:\libpng\libpng.a C:\zlib\lib\libz.a C:\zlib\lib\libz.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x4d4): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x5ab): undefined reference to `GOMP_critical_name_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x5b7): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x695): undefined reference to `GOMP_critical_name_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x1547): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x15ba): undefined reference to `GOMP_critical_name_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x179e): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x182e): undefined reference to `GOMP_critical_name_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x1985): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x19fd): undefined reference to `GOMP_critical_name_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x236f): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x23d8): undefined reference to `GOMP_critical_name_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x2d2b): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x2da3): undefined reference to `GOMP_critical_name_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x300b): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x307f): undefined reference to `GOMP_critical_name_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x33dc): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x3457): undefined reference to `GOMP_critical_name_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x3e5d): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x3f4a): undefined reference to `GOMP_critical_name_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x647c): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x655f): undefined reference to `GOMP_critical_name_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x6ca8): undefined reference to `GOMP_critical_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x6f37): undefined reference to `omp_set_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x6ff5): undefined reference to `omp_unset_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x7294): undefined reference to `GOMP_critical_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x744e): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x7476): undefined reference to `GOMP_critical_name_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x74fb): undefined reference to `omp_destroy_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x752b): undefined reference to `omp_set_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x7609): undefined reference to `omp_unset_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x77f3): undefined reference to `omp_set_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x78d6): undefined reference to `omp_unset_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x7913): undefined reference to `omp_set_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x79f6): undefined reference to `omp_unset_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x7a33): undefined reference to `omp_set_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x7b16): undefined reference to `omp_unset_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x7b6e): undefined reference to `omp_set_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x7c12): undefined reference to `omp_unset_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x7c46): undefined reference to `omp_set_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x7d97): undefined reference to `omp_unset_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x8789): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0x87d9): undefined reference to `GOMP_critical_name_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0xa34a): undefined reference to `omp_init_lock'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0xae9f): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0xaf1c): undefined reference to `GOMP_critical_name_end'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0xb597): undefined reference to `GOMP_critical_name_start'
CMakeFiles\mgl.dir/objects.a(base.cpp.obj):base.cpp:(.text+0xb61c): undefined reference to `GOMP_critical_name_end'
c:/codeblocks/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: CMakeFiles\mgl.dir/objects.a(base.cpp.obj): bad reloc address 0x120 in section `.data'
collect2.exe: error: ld returned 1 exit status
src\CMakeFiles\mgl.dir\build.make:1265: recipe for target ' src/libmgl.dll' failed
mingw32-make[3]: *** [src/libmgl.dll] Error 1
mingw32-make[3]: Leaving directory ' c:/mathgl-2.3'
CMakeFiles\Makefile2:82: recipe for target ' src/CMakeFiles/mgl.dir/all' failed
mingw32-make[2]: *** [src/CMakeFiles/mgl.dir/all] Error 2
mingw32-make[2]: Leaving directory ' c:/mathgl-2.3'
Makefile:118: recipe for target ' all' failed
mingw32-make[1]: *** [all] Error 2
mingw32-make[1]: Leaving directory ' c:/mathgl-2.3'
Oct 20, 2014 at 4:05pm UTC
Does this help?
There is known bug for building in MinGW – you need to manually add linker option -fopenmp (i.e. CMAKE_EXE_LINKER_FLAGS:STRING='-fopenmp' and CMAKE_SHARED_LINKER_FLAGS:STRING='-fopenmp') if you enable OpenMP support (i.e. if enable-openmp=ON).
From the MathGl website:
http://mathgl.sourceforge.net/doc_en/Installation.html#Installation
Oct 20, 2014 at 4:35pm UTC
I looked at this, but thanks anyway.
It doesn't seem to work. Not sure what else I can do..
Oct 20, 2014 at 5:05pm UTC
Not trying to be a know it all, but did you:
1. run cmake
2. edit CMakeCache.txt to add the above lines.
3. run make
Oct 22, 2014 at 4:16am UTC
I've added that to the Cmake Cache text file as you've mentioned and I also had to add in this to the top of the cmakelists.txt file as there was an error because the OpenMP_CXX_FLAGS could not be found.
set (OpenMP_CXX_FLAGS "-fopenmp" )
While I can complete the configure process using cmake I now get the below error during the actual build process. Not sure why.
I downloaded OpenMP and added an environmental variable for libgomp but still get the below error.
g++.exe: error: libgomp.spec: No such file or directory
Oct 22, 2014 at 5:37am UTC
I ended up using this solution:
http://mingw.5.n7.nabble.com/MingGW-and-OpenMP-td30056.html
The problem was I didn't have mingw-get installed so the commands weren't working to install libgomp. Once I installed that I applied the below in MSYS and the MathGL was able to build. past the 46% mark. It's still going but if it completes I'll mark this as solved.:
mingw-get install mingw32-libgomp
Thanks for the help.
Topic archived. No new replies allowed.