Hi,

The latest Clang-6.0 compiler finally enables OpenMP by default on
Linux (e.g. Ubuntu-18 x86_64).

But OpenMP programs using Clang-6.0/CMake-3.10 fail to compile:

[100%] Linking CXX executable primecount
libprimecount.a(P2.cpp.o): In function `.omp_outlined..7':
P2.cpp:(.text+0x2194): undefined reference to `__atomic_load'
P2.cpp:(.text+0x21ef): undefined reference to `__atomic_compare_exchange'
CMakeFiles/primecount.dir/build.make:148: recipe for target 'primecount'
failed
make[2]: *** [primecount] Error 1

The problem is that:

target_link_libraries(myprogram OpenMP::OpenMP_CXX)

does not add libatomic to the linker options which LLVM/Clang's OpenMP
library depends upon. When I manually add -latomic to the linker
options my OpenMP programs compile & link fine using Clang-6.0/CMake-3.10.

Regards,
Kim
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to