how to link libclang and libtooling to QT project
-
I want to build AST using clang library in my project.
In my main.cpp file I have following:#include <clang/Tooling/Tooling.h> #include <clang/AST/ASTConsumer.h> #include <clang/AST/RecursiveASTVisitor.h>I added this to my .pro file:
INCLUDEPATH += /home/jdenv/rep/libs/llvm-project/install/include/ INCLUDEPATH += /home/jdenv/rep/libs/llvm-project/install/include/clang/ INCLUDEPATH += /home/jdenv/rep/libs/llvm-project/install/include/llvm/ LIBS += -L /home/jdenv/rep/libs/llvm-project/install/lib -lclang LIBS += /home/jdenv/rep/libs/llvm-project/install/lib/libLLVMSupport.so LIBS += /home/jdenv/rep/libs/llvm-project/install/lib/libclangTooling.so autocompletion and code highlighting in editor work normal, but when I try to build, I get an error:  What should I do? I've never linked libraries before so I would be very grateful for your help -
I want to build AST using clang library in my project.
In my main.cpp file I have following:#include <clang/Tooling/Tooling.h> #include <clang/AST/ASTConsumer.h> #include <clang/AST/RecursiveASTVisitor.h>I added this to my .pro file:
INCLUDEPATH += /home/jdenv/rep/libs/llvm-project/install/include/ INCLUDEPATH += /home/jdenv/rep/libs/llvm-project/install/include/clang/ INCLUDEPATH += /home/jdenv/rep/libs/llvm-project/install/include/llvm/ LIBS += -L /home/jdenv/rep/libs/llvm-project/install/lib -lclang LIBS += /home/jdenv/rep/libs/llvm-project/install/lib/libLLVMSupport.so LIBS += /home/jdenv/rep/libs/llvm-project/install/lib/libclangTooling.so autocompletion and code highlighting in editor work normal, but when I try to build, I get an error:  What should I do? I've never linked libraries before so I would be very grateful for your help@jdenv said in how to link libclang and libtooling to QT project:
LIBS += -L /home/jdenv/rep/libs/llvm-project/install/lib -lclang
LIBS += /home/jdenv/rep/libs/llvm-project/install/lib/libLLVMSupport.so
LIBS += /home/jdenv/rep/libs/llvm-project/install/lib/libclangTooling.soThis is wrong. Should be:
LIBS+=-L/home/jdenv/rep/libs/llvm-project/install/lib -lclang LIBS+=-L/home/jdenv/rep/libs/llvm-project/install/lib -lLLVMSupport LIBS+=-L/home/jdenv/rep/libs/llvm-project/install/lib -lclangToolingThe picture with the error you posted is not visible. Please post errors as text.
-
@jdenv said in how to link libclang and libtooling to QT project:
LIBS += -L /home/jdenv/rep/libs/llvm-project/install/lib -lclang
LIBS += /home/jdenv/rep/libs/llvm-project/install/lib/libLLVMSupport.so
LIBS += /home/jdenv/rep/libs/llvm-project/install/lib/libclangTooling.soThis is wrong. Should be:
LIBS+=-L/home/jdenv/rep/libs/llvm-project/install/lib -lclang LIBS+=-L/home/jdenv/rep/libs/llvm-project/install/lib -lLLVMSupport LIBS+=-L/home/jdenv/rep/libs/llvm-project/install/lib -lclangToolingThe picture with the error you posted is not visible. Please post errors as text.
@jsulm I've edited LIBS like you said, but I still get following errors:
main.o: undefined reference to symbol '_ZN5clang14FrontendAction13EndSourceFileEv'
/home/jdenv/rep/libs/llvm-project/install/lib/../lib/libclangFrontend.so.22.0git: error adding symbols: DSO missing from command line -
Hi,
Are you sure you are linking all the required libraries ?
-
@jsulm I've edited LIBS like you said, but I still get following errors:
main.o: undefined reference to symbol '_ZN5clang14FrontendAction13EndSourceFileEv'
/home/jdenv/rep/libs/llvm-project/install/lib/../lib/libclangFrontend.so.22.0git: error adding symbols: DSO missing from command line@jdenv said in how to link libclang and libtooling to QT project:
main.o: undefined reference to symbol '_ZN5clang14FrontendAction13EndSourceFileEv'
Looks like one of the clang libraries is missing