Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to link libclang and libtooling to QT project
Forum Updated to NodeBB v4.3 + New Features

how to link libclang and libtooling to QT project

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 74 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jdenv
    wrote last edited by
    #1

    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:
    ![7f7890aa-4e3f-4dd5-8a4f-089645d9bc97-изображение.png](https://ddgobkiprc33d.cloudfront.net/b83810f6-abef-428f-9153-60364d6bea88.png) 
    
    What should I do? I've never linked libraries before so I would be very grateful for your help
    jsulmJ 1 Reply Last reply
    0
    • J Offline
      J Offline
      jdenv
      wrote last edited by
      #2

      seems like something wrong with the image, so the error i get is
      /home/jdenv/rep/libs/llvm-project/install/lib/../lib/libclangFrontend.so.22.0git: error adding symbols: DSO missing from command line

      1 Reply Last reply
      0
      • J jdenv

        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:
        ![7f7890aa-4e3f-4dd5-8a4f-089645d9bc97-изображение.png](https://ddgobkiprc33d.cloudfront.net/b83810f6-abef-428f-9153-60364d6bea88.png) 
        
        What should I do? I've never linked libraries before so I would be very grateful for your help
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote last edited by
        #3

        @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.so

        This 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 -lclangTooling
        

        The picture with the error you posted is not visible. Please post errors as text.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        J 1 Reply Last reply
        1
        • jsulmJ jsulm

          @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.so

          This 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 -lclangTooling
          

          The picture with the error you posted is not visible. Please post errors as text.

          J Offline
          J Offline
          jdenv
          wrote last edited by
          #4

          @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

          jsulmJ 1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote last edited by
            #5

            Hi,

            Are you sure you are linking all the required libraries ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • J jdenv

              @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

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote last edited by
              #6

              @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

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved