[cfe-dev] Can't compile simple OpenMP code with clang 5.0.0

Johannes Doerfert via cfe-dev cfe-dev at lists.llvm.org
Tue Dec 22 13:48:07 PST 2020


Hi Kerim,

I tried to help below. Looking at xeus-cling I did not immediately see 
why clang 5 is
required. If this doesn't work as described below, I might spend time 
trying to get it
to run with clang 11 ;)

On 12/22/20 1:57 PM, Керим Хемраев via cfe-dev wrote:
> Hi,
>   
> I’m struggling with compiling simple OpenMP program with clang 5.0.0.
> Here is the code (foo.cxx):
>   
> #include   "omp.h"
> #include   <stdio.h>
> int   main ( void ) {
>     #pragma   omp   parallel
>     printf ( "thread %d \n " ,  omp_get_thread_num ());
> }
>   
> As I use clang as part of xeus-cling my clang installation is inside conda packages:
> $  which clang
> /home/tasik/miniconda3/envs/cling/bin/clang
>   
> As this clang package does’t have  omp.h I provide additional directories to find  omp.h  and  libomp.so
> To compile the code I use the command:
> $ clang -fopenmp -I/home/../usr/lib/llvm-10/include/openmp/ -L/home/../usr/lib/llvm-10/lib foo.cxx
>   
> And I get errors:
> /usr/bin/ld: cannot find /lib64/libpthread.so.0
> /usr/bin/ld: cannot find /usr/lib64/libpthread_nonshared.a
> clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

The error basically means clang looks for the libthread libraries and 
cannot find them.
Check on you system where they are and provide the path via -L to clang. 
That might allow
you to proceed. That said, I don't think you are able to mix clang 5 and 
llvm 10 as you
do now. The headers and libraries clang might pick up need to be 
consistent (with the clang
version). At least, you need to make sure `omp.h` and `libomp.so` are 
the ones shipped with
clang 5.

~ Johannes


>   
> I really need some help to undertand how to work with clang 5.0.0 OpenMP
> And I think that it is difficult to update clang’s version as xeus-cling requires mentioned 5.0.0 version...
>   
>   
> With respect,
> kerim
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


More information about the cfe-dev mailing list