Friday, October 29, 2021

[SOLVED] How to force llvm cmake to use only given path to libs?

Issue

I try to build llvm on a system where I have no root access. So, I've got some problems: I have been obliged to install gcc, cmake in my $HOME path because system's gcc and cmake are very old and I cannot update them with sudo.

I finely installed gcc and cmake and mentioned new paths to PATH env variable. I ran cmake for llvm with this:

cmake -S llvm -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON -DLLVM_TARGETS_TO_BUILD=all -DLLVM_ENABLE_PROJECTS="clang;lld" -DCMAKE_INSTALL_PREFIX=/home/my_user/local  -DCMAKE_C_COMPILER=/home/my_user/local/bin/gcc -DCMAKE_LIBRARY_PATH=/home/my_user/local/lib ../llvm

It successfully generate make-file. When I run, it throws:

../../../../bin/clang-tblgen: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by ../../../../bin/clang-tblgen)
../../../../bin/clang-tblgen: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ../../../../bin/clang-tblgen)
...

but I've already got convenient libstdc++.so.6 in my /home/my_user/local/lib64 and /home/my_user/local/lib when I installed new gcc but I don't understand how to force cmake or make to consider only these paths instead /lib64. What an option should I pass to cmake or do I need to add some env variable to fix the problem?


Solution

I found a solution that worked out for me. Find out what a path contains needed libraries (in my case it is /home/my_user/local/lib64 and then run LD_LIBRARY_PATH=/home/my_user/local/lib64 make!



Answered By - MadMax