<HTML><BODY><div>Thank you!</div><div>The command:</div><div>$ <em>clang++-10 -fopenmp foo.cxx</em></div><div> </div><div>successfully builds. </div><div>$ <em>./a.out</em></div><div><em>thread 1<br>thread 2<br>thread 0<br>thread 3</em></div><div> </div><div>Now I think we can go back to xeus-cling :)</div><div> </div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">Среда, 23 декабря 2020, 2:57 +03:00 от Johannes Doerfert <johannesdoerfert@gmail.com>:<br> <div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_16086814332142370737_BODY">clang++-10 -fopenmp foo.cxx  (or whatever the clang++ symlink is called)<br><br>~ Johannes<br><br><br>On 12/22/20 5:37 PM, Керим Хемраев wrote:<div class="mail-quote-collapse">> The command:<br>> $ clang-10 -fopenmp foo.cxx<br>><br>> gives the error output:<br>> /usr/bin/ld: /tmp/foo-e2d536.o: in function `__clang_call_terminate':<br>> foo.cxx:(.text.__clang_call_terminate[__clang_call_terminate]+0x2): undefined reference to `__cxa_begin_catch'<br>> /usr/bin/ld: foo.cxx:(.text.__clang_call_terminate[__clang_call_terminate]+0xb): undefined reference to `std::terminate()'<br>> /usr/bin/ld: /tmp/foo-e2d536.o:(.eh_frame+0x4b): undefined reference to `__gxx_personality_v0'<br>> clang: error: linker command failed with exit code 1 (use -v to see invocation)<br>><br>>> Среда, 23 декабря 2020, 2:33 +03:00 от Johannes Doerfert <<a href="/compose?To=johannesdoerfert@gmail.com">johannesdoerfert@gmail.com</a>>:<br>>><br>>> I think libomp is still on version 5.0, (I know, I know).<br>>> It is not coupled to LLVM wrt. version numbers.<br>>><br>>> Last time I checked, LLVM build for debian (and Ububuntu)<br>>> came bundled with the OpenMP runtimes (for the host). That<br>>> means you should not need libomp-5-dev but just clang-10.<br>>> libomp-5-dev is useful if you *don't* want clang but still<br>>> target libomp, which is the LLVM OpenMP host runtime, from<br>>> gcc, thus use it as a replacement of libgomp.<br>>><br>>> All that said, doesn't `clang-10 -fopenmp ...` "just work"?<br>>><br>>> ~ Johannes<br>>><br>>><br>>> On 12/22/20 5:28 PM, Керим Хемраев wrote:<br>>>> Hi Johannes,<br>>>><br>>>> Thank you for response<br>>>><br>>>> It seems that I don’t have   libthread. Moreover it is highly likely that omp.h and libomp.so that I used to provide as parameters to clang are not shipped with clang 5 :)<br>>>><br>>>> I think I should now forget about xeus-cling for a while and simply build the code with latest (or any) version of clang with OpenMP.<br>>>><br>>>> I’ve tried to do the following:<br>>>> $ sudo apt-get install clang-10<br>>>> $ sudo apt-get install libomp-5-dev<br>>>><br>>>> Now I want to find where are these packages were installed:<br>>>> $ find  /usr -iname clang-10<br>>>> /usr/lib/llvm-10/bin/clang-10<br>>>> /usr/lib/cmake/clang-10<br>>>> /usr/share/doc/clang-10<br>>>> /usr/share/bash-completion/completions/clang-10<br>>>> /usr/share/lintian/overrides/clang-10<br>>>> /usr/bin/clang-10<br>>>><br>>>> $ find  /usr -iname libomp-10-dev<br>>>> /usr/share/doc/libomp-10-dev<br>>>><br>>>> So I’m afraid that  libomp-10-dev  contains only some docs and there is no library   libomp-10-dev.so (or something)<br>>>><br>>>> Could you please guide me how to properly install clang with OpenMP that I could build my test script?<br>>>><br>>>> I’m on Ubuntu  20.04, x64<br>>>> $ cat /etc/lsb-release<br>>>> DISTRIB_ID=Ubuntu<br>>>> DISTRIB_RELEASE=20.04<br>>>> DISTRIB_CODENAME=focal<br>>>> DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"<br>>>><br>>>>> Среда, 23 декабря 2020, 0:48 +03:00 от Johannes Doerfert < <a href="/compose?To=johannesdoerfert@gmail.com">johannesdoerfert@gmail.com</a> >:<br>>>>><br>>>>> Hi Kerim,<br>>>>><br>>>>> I tried to help below. Looking at xeus-cling I did not immediately see<br>>>>> why clang 5 is<br>>>>> required. If this doesn't work as described below, I might spend time<br>>>>> trying to get it<br>>>>> to run with clang 11 ;)<br>>>>><br>>>>> On 12/22/20 1:57 PM, Керим Хемраев via cfe-dev wrote:<br>>>>>> Hi,<br>>>>>><br>>>>>> I’m struggling with compiling simple OpenMP program with clang 5.0.0.<br>>>>>> Here is the code (foo.cxx):<br>>>>>><br>>>>>> #include   "omp.h"<br>>>>>> #include   <stdio.h><br>>>>>> int   main ( void ) {<br>>>>>>    #pragma   omp   parallel<br>>>>>>    printf ( "thread %d \n " ,  omp_get_thread_num ());<br>>>>>> }<br>>>>>><br>>>>>> As I use clang as part of xeus-cling my clang installation is inside conda packages:<br>>>>>> $ which clang<br>>>>>> /home/tasik/miniconda3/envs/cling/bin/clang<br>>>>>><br>>>>>> As this clang package does’t have omp.h I provide additional directories to find omp.h and libomp.so<br>>>>>> To compile the code I use the command:<br>>>>>> $ clang -fopenmp -I/home/../usr/lib/llvm-10/include/openmp/ -L/home/../usr/lib/llvm-10/lib foo.cxx<br>>>>>><br>>>>>> And I get errors:<br>>>>>> /usr/bin/ld: cannot find /lib64/libpthread.so.0<br>>>>>> /usr/bin/ld: cannot find /usr/lib64/libpthread_nonshared.a<br>>>>>> clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)<br>>>>> The error basically means clang looks for the libthread libraries and<br>>>>> cannot find them.<br>>>>> Check on you system where they are and provide the path via -L to clang.<br>>>>> That might allow<br>>>>> you to proceed. That said, I don't think you are able to mix clang 5 and<br>>>>> llvm 10 as you<br>>>>> do now. The headers and libraries clang might pick up need to be<br>>>>> consistent (with the clang<br>>>>> version). At least, you need to make sure `omp.h` and `libomp.so` are<br>>>>> the ones shipped with<br>>>>> clang 5.<br>>>>><br>>>>> ~ Johannes<br>>>>><br>>>>><br>>>>>> I really need some help to undertand how to work with clang 5.0.0 OpenMP<br>>>>>> And I think that it is difficult to update clang’s version as xeus-cling requires mentioned 5.0.0 version...<br>>>>>><br>>>>>><br>>>>>> With respect,<br>>>>>> kerim<br>>>>>><br>>>>>> _______________________________________________<br>>>>>> cfe-dev mailing list<br>>>>>> <a href="/compose?To=cfe%2ddev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>>>>>> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>>>><br>>>> С уважением,<br>>>> Керим Хемраев<br>>>> <a href="/compose?To=kerim.khemraev@mail.ru">kerim.khemraev@mail.ru</a><br>>>><br>><br>><br>> С уважением,<br>> Керим Хемраев<br>> <a href="/compose?To=kerim.khemraev@mail.ru">kerim.khemraev@mail.ru</a><br>></div></div></div></div></div></blockquote><div> <div> </div><div data-signature-widget="container"><div data-signature-widget="content"><div>С уважением,<br>Керим Хемраев<br>kerim.khemraev@mail.ru</div></div></div><div> </div></div></BODY></HTML>