Error starting program using exchange library

There is a code like this:

#include <cstdlib> #include <clang-c/Index.h> using namespace std; int main(int argc, char** argv) { CXIndex Index = clang_createIndex(0, 0); CXTranslationUnit TU = clang_parseTranslationUnit(Index, 0, argv, argc, 0, 0, CXTranslationUnit_None); for (unsigned I = 0, N = clang_getNumDiagnostics(TU); I != N; ++I) { CXDiagnostic Diag = clang_getDiagnostic(TU, I); CXString String = clang_formatDiagnostic(Diag, clang_defaultDiagnosticDisplayOptions()); fprintf(stderr, "%s\n", clang_getCString(String)); clang_disposeString(String); } clang_disposeTranslationUnit(TU); clang_disposeIndex(Index); return 0; } 

And it is compiled with the following flags:

 g++ main.cpp -g -fno-rtti `llvm-config --cxxflags --ldflags --libs` -lclang -o main 

However, when I want to run main:

 ./main 

then the following error occurs:

 ./main: error while loading shared libraries: libclang.so: cannot open shared object file: No such file or directory 

But:

 $ sudo find / -name libclang.so /usr/local/lib/libclang.so 

The library seems to be in place. How to run this program?

+4
source share
1 answer

ldconfig creates the necessary links and caches the most recent shared libraries found in the directories specified in the line command in the /etc/ld.so.conf file and in the trusted directories (/ lib and / usr / lib)

Try running /sbin/ldconfig , and then if that doesn't work, try adding the /etc/ld.so.conf file with "/ usr / local / lib" and then run /sbin/ldconfig

Teams

  • Run the following command and then try compiling / executing again

    / SBIN / LDCONFIG

  • If this does not work, do it and then try compiling / executing again

    echo "/ usr / local / lib" โ†’ /etc/ld.so.conf / SBIN / LDCONFIG

+4
source

Source: https://habr.com/ru/post/1382761/


All Articles