GPU offloading with clang


I'm trying to use openmp offloading to gpu, and I'm getting linking errors
during compilation:

[ 7%] Linking CXX executable MPI_PMRF
undefined reference to `.omp_offloading.entries_begin'
undefined reference to `.omp_offloading.entries_end'
undefined reference to `.omp_offloading.entries_begin'
undefined reference to `.omp_offloading.entries_end'
/usr/bin/ld: link errors found, deleting executable `MPI_PMRF'
clang-9: error: linker command failed with exit code 1 (use -v to see
CMakeFiles/MPI_PMRF.dir/build.make:265: recipe for target 'MPI_PMRF' failed
make[2]: *** [MPI_PMRF] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/MPI_PMRF.dir/all'
make[1]: *** [CMakeFiles/MPI_PMRF.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

I actually can compile the code just fine without the #pragma omp target.

Some additional info:

- I'm compiling the code with *-fopenmp

- *clang version 9.0.0* (
e50a43ae7e2fe6e6ff515cedb2a8ae658120e32f) (

- *cuda info:*

Hi Talita,

You may be linking against the wrong OpenMP library.

Have you built the OpenMP runtime library? If you have you then also need to set up your environment to pick it up instead of some other default option. To be sure you use the library you intend you can use the -I and -L compiler flags to pass the location of the omp.h header file and the runtime library you intend to use.



Hi Doru,

Thanks for your reply. I think I figured out the problem. But now I’m having another issue:

nvlink fatal : Could not open input file ‘/usr/common/software/opencv/3.1.0/gnu/lib/’
clang-9: error: nvlink command failed with exit code 1 (use -v to see invocation)
CMakeFiles/MPI_PMRF.dir/build.make:257: recipe for target ‘MPI_PMRF’ failed