Error while running configure "Cannot locate libclang or headers"

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri Nov 20 14:48:36 UTC 2020


On 20/11/2020 14:33, Jorn Vernee wrote:
> Hi,
>
> AFAIK if you're building from sources you need to use the cmake 
> install target for it to produce a "package" that you can use I think 
> some headers might otherwise be missing.
>
>     cmake --build <build dir> --target install
>
> That will install at whatever CMAKE_INSTALL_PREFIX is set to 
> (recommend setting this explicitly, instead of using the default). You 
> can point the jdk build at that afterwards package.
>
> That said, using a binary distribution might be easier, since it 
> should already have the right directory structure.

I wonder if (i) the binary distro you have tried is compatible with 
19.10 - I remember trying out several available on the LLVM website few 
months ago, and none of them worked out of the box on Ubuntu 20.04 
(while many do on Ubuntu 18.04). Maybe 19.10 is in a similar boat?

So it could be both the paths you tried fail, but for different reasons 
- as Jorn mentioned, the build you have might not be 100% ok - and the 
binary you downloaded might have dependencies that are not satisfied on 
your system.

The gcc test I suggested in the previous email should help in narrowing 
this down - if you see compilation/linker issues there, then we know 
where to look.

Maurizio

>
> HTH,
> Jorn
>
> On 20/11/2020 12:52, Maurizio Cimadamore wrote:
>>
>> On 19/11/2020 21:51, Vipin Sharma wrote:
>>> dir: /home/vipin/Downloads/clang+llvm-9.0.0-x86_64-pc-linux-gnu
>>> libexec
>>> include
>>> share
>>> lib
>>> bin
>>
>> This looks totally ok.
>>
>> Just one more test: can you run `clang` from there? Or do you get 
>> errors pointing at missing dependencies?
>>
>> This is really odd. I have basically the same setup (except for newer 
>> Ubuntu), I have built clang sources from scratch, then pointed the 
>> JDK build to the LLVM build folder and it all worked out.
>>
>> If all else fail, it would be nice to try and do what autoconf is 
>> trying to do, which is to compile a small program against libclang 
>> include/library and see if that works correctly. Something like:
>>
>> ```
>> $ cat testClang.c
>> #include "clang-c/Index.h"
>>
>> int main(void) {
>>    clang_getClangVersion();
>>    return 0;
>> }
>> ```
>>
>> Then try to compile it using gcc, and supply the "-I" (capital i) 
>> option to point at the LLVM include folder, "-L" to point at LLVM lib 
>> folder, and then "-l clang" (lower case "L") to set linker dependency 
>> on libclang.
>>
>> E.g - in my system:
>>
>> ```
>> gcc -I/opt/clang/llvm-10/include -L/opt/clang/llvm-10/lib testClang.c 
>> -lclang
>> ```
>>
>> If you get compilation errors, or linker errors, then there's 
>> something up with the environment. AFAIK, autoconf does something 
>> like that to "check that libclang is really there".
>>
>> Maurizio
>>
>>
>>
>>


More information about the panama-dev mailing list