- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I compile a program using clang++, an error appeared like below:
/opt/software/intel/llvm/build/bin/clang++ -O3 -L/opt/software/intel/llvm/build/lib -fopenmp -lstdc++ -fsycl-early-optimizations -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_80 -I/opt/intel/oneapi/compiler/2024.1/include CMakeFiles/cmTC_4c21c.dir/testCXXCompiler.cxx.o -o cmTC_4c21c
/usr/bin/ld: cannot find -lomp
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[1]: *** [CMakeFiles/cmTC_4c21c.dir/build.make:100: cmTC_4c21c] Error 1
I noticed that there is no libruaries like "libiomp*" or "libomp*" under /opt/software/intel/llvm/build/lib. what should I do if I need to link openmp when using clang++?
By the way, I installed LLVM following Getting Started with oneAPI DPC++ — oneAPI DPC++ Compiler documentation (intel.github.io)
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In the dpc++ compiler shipped in Intel oneapi base toolkit, there're openmp libraries:
For example for compiler 2024.1, you can find the following files,
intel/oneapi/compiler/2024.1/lib/libiomp5.a
intel/oneapi/compiler/2024.1/lib32/libiomp5.a
You're using the open source version, maybe there're special options to build the openmp libraries ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I linked the libraries following your suggestions, and then I got errors sa below:
-- The CXX compiler identification is Clang 18.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /opt/software/intel/llvm/build/bin/clang++
-- Check for working CXX compiler: /opt/software/intel/llvm/build/bin/clang++ - broken
CMake Error at /opt/cloudsc/cmake-3.29.0-linux-x86_64/share/cmake-3.29/Modules/CMakeTestCXXCompiler.cmake:60 (message):
The C++ compiler
"/opt/software/intel/llvm/build/bin/clang++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: '/opt/cloudsc_sycl_clang/test2/build-sycl/CMakeFiles/CMakeScratch/TryCompile-eVfOoL'
Run Build Command(s): /opt/cloudsc/cmake-3.29.0-linux-x86_64/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_ef72f/fast
/usr/bin/gmake -f CMakeFiles/cmTC_ef72f.dir/build.make CMakeFiles/cmTC_ef72f.dir/build
gmake[1]: Entering directory '/opt/cloudsc_sycl_clang/test2/build-sycl/CMakeFiles/CMakeScratch/TryCompile-eVfOoL'
Building CXX object CMakeFiles/cmTC_ef72f.dir/testCXXCompiler.cxx.o
/opt/software/intel/llvm/build/bin/clang++ -O3 -L/opt/software/gcc122/lib64 -lstdc++ -L/opt/intel/oneapi/compiler/2024.1/lib -fopenmp -fsycl-early-optimizations -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_80 -I/opt/intel/oneapi/compiler/2024.1/include -I/opt/software/gcc122/include/c++/12.2.0 -MD -MT CMakeFiles/cmTC_ef72f.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_ef72f.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_ef72f.dir/testCXXCompiler.cxx.o -c /opt/cloudsc_sycl_clang/test2/build-sycl/CMakeFiles/CMakeScratch/TryCompile-eVfOoL/testCXXCompiler.cxx
clang++: warning: -Z-reserved-lib-stdc++: 'linker' input unused [-Wunused-command-line-argument]
Linking CXX executable cmTC_ef72f
/opt/cloudsc/cmake-3.29.0-linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ef72f.dir/link.txt --verbose=1
/opt/software/intel/llvm/build/bin/clang++ -O3 -L/opt/software/gcc122/lib64 -lstdc++ -L/opt/intel/oneapi/compiler/2024.1/lib -fopenmp -fsycl-early-optimizations -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_80 -I/opt/intel/oneapi/compiler/2024.1/include -I/opt/software/gcc122/include/c++/12.2.0 CMakeFiles/cmTC_ef72f.dir/testCXXCompiler.cxx.o -o cmTC_ef72f
/usr/bin/ld: cannot find -lomp
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[1]: *** [CMakeFiles/cmTC_ef72f.dir/build.make:100: cmTC_ef72f] Error 1
gmake[1]: Leaving directory '/opt/cloudsc_sycl_clang/test2/build-sycl/CMakeFiles/CMakeScratch/TryCompile-eVfOoL'
gmake: *** [Makefile:127: cmTC_ef72f/fast] Error 2
I have a few questions:
(1) I have no idea why clang++ broken. Before I compiled the program above, I compiled an exapmle program, which is oneAPI-samples-master/DirectProgramming/C++SYCL/DenseLinearAlgebra/vector-add/src/vector-add-buffers.cpp, and it went well. And I compiled and ran it using the following commands:
$clang++ -fsycl -fsycl-targets=nvptx64-nvidia-cuda vector-add-buffers.cpp -o vector-add-buffers -L /opt/software/gcc122/lib64 -lstdc++
$ONEAPI_DEVICE_SELECTOR=cuda:7 ./vector-add-buffers
(2) About the 'linker' input unused and /usr/bin/ld: cannot find -lomp. I think I have linked the right libraries?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
For the 1st question, is the error due to the added library path ?
For the 2nd question, can you try the option "-liomp5" ? With option "-lomp", the linker is looking for libomp.a.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
By changing the option from "-fopenmp" to "-liomp5", the errors disappeared.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe give this a try?
python3 ../buildbot/configure.py --llvm-external-projects=openmp
python3 ../buildbot/compile.py
python3 ../buildbot/compile.py -t omp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for your suggestions. As changing the option solved my problem, I'll write your suggestions down and try it later.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page