[cmake-developers] [CMake 0015393]: undefined reference to `GOMP_parallel'

Mantis Bug Tracker mantis at public.kitware.com
Mon Feb 9 11:09:32 EST 2015


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=15393 
====================================================================== 
Reported By:                Mathieu Malaterre
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15393
Category:                   (No Category)
Reproducibility:            have not tried
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-02-09 11:09 EST
Last Modified:              2015-02-09 11:09 EST
====================================================================== 
Summary:                    undefined reference to `GOMP_parallel'
Description: 
This is a follow-up to http://www.cmake.org/Bug/view.php?id=15392. See steps to
reproduce.

It make the module hard to use in a portable manner.

Steps to Reproduce: 
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(omp C)
find_package(OpenMP REQUIRED)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
add_library(tomp SHARED tomp.c)
$ cat tomp.c
#include <math.h>

int compute()
{
  const int size = 256;
  double table[size];

  int n;
#pragma omp parallel for
  for(n=0; n<size; ++n)
    table[n] = 0;

  return table[size-1];
}
$ cat toolchain-mingw64.cmake
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)

Then:

$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchain-mingw64.cmake
-- The C compiler identification is GNU 4.9.1
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Try OpenMP C flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Found OpenMP: -fopenmp  
-- Configuring done
-- Generating done
-- Build files have been written to:
/home/mathieu/Projects/intranet/junk/omp/bin
$ make VERBOSE=1
/usr/bin/cmake -H/home/mathieu/Projects/intranet/junk/omp
-B/home/mathieu/Projects/intranet/junk/omp/bin --check-build-system
CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start
/home/mathieu/Projects/intranet/junk/omp/bin/CMakeFiles
/home/mathieu/Projects/intranet/junk/omp/bin/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/mathieu/Projects/intranet/junk/omp/bin'
make -f CMakeFiles/tomp.dir/build.make CMakeFiles/tomp.dir/depend
make[2]: Entering directory '/home/mathieu/Projects/intranet/junk/omp/bin'
cd /home/mathieu/Projects/intranet/junk/omp/bin && /usr/bin/cmake -E
cmake_depends "Unix Makefiles" /home/mathieu/Projects/intranet/junk/omp
/home/mathieu/Projects/intranet/junk/omp
/home/mathieu/Projects/intranet/junk/omp/bin
/home/mathieu/Projects/intranet/junk/omp/bin
/home/mathieu/Projects/intranet/junk/omp/bin/CMakeFiles/tomp.dir/DependInfo.cmake
--color=
make[2]: Leaving directory '/home/mathieu/Projects/intranet/junk/omp/bin'
make -f CMakeFiles/tomp.dir/build.make CMakeFiles/tomp.dir/build
make[2]: Entering directory '/home/mathieu/Projects/intranet/junk/omp/bin'
/usr/bin/cmake -E cmake_progress_report
/home/mathieu/Projects/intranet/junk/omp/bin/CMakeFiles 1
[100%] Building C object CMakeFiles/tomp.dir/tomp.c.obj
/usr/bin/x86_64-w64-mingw32-gcc  -Dtomp_EXPORTS -fopenmp   -o
CMakeFiles/tomp.dir/tomp.c.obj   -c
/home/mathieu/Projects/intranet/junk/omp/tomp.c
Linking C shared library libtomp.dll
/usr/bin/cmake -E cmake_link_script CMakeFiles/tomp.dir/link.txt --verbose=1
/usr/bin/cmake -E remove -f CMakeFiles/tomp.dir/objects.a
/usr/bin/x86_64-w64-mingw32-ar cr CMakeFiles/tomp.dir/objects.a
@CMakeFiles/tomp.dir/objects1.rsp
/usr/bin/x86_64-w64-mingw32-gcc     -shared -o libtomp.dll
-Wl,--out-implib,libtomp.dll.a
-Wl,--major-image-version,0,--minor-image-version,0 -Wl,--whole-archive
CMakeFiles/tomp.dir/objects.a -Wl,--no-whole-archive -lkernel32 -luser32 -lgdi32
-lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 
CMakeFiles/tomp.dir/objects.a(tomp.c.obj):tomp.c:(.text+0xa2): undefined
reference to `GOMP_parallel'
CMakeFiles/tomp.dir/objects.a(tomp.c.obj):tomp.c:(.text+0xf1): undefined
reference to `omp_get_num_threads'
CMakeFiles/tomp.dir/objects.a(tomp.c.obj):tomp.c:(.text+0xf8): undefined
reference to `omp_get_thread_num'
collect2: error: ld returned 1 exit status
CMakeFiles/tomp.dir/build.make:86: recipe for target 'libtomp.dll' failed
make[2]: *** [libtomp.dll] Error 1
make[2]: Leaving directory '/home/mathieu/Projects/intranet/junk/omp/bin'
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/tomp.dir/all' failed
make[1]: *** [CMakeFiles/tomp.dir/all] Error 2
make[1]: Leaving directory '/home/mathieu/Projects/intranet/junk/omp/bin'
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-02-09 11:09 Mathieu MalaterreNew Issue                                    
======================================================================



More information about the cmake-developers mailing list