Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. CLangCodeModel, libclang command line arguments and cross-compiling
QtWS25 Last Chance

CLangCodeModel, libclang command line arguments and cross-compiling

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
2 Posts 2 Posters 577 Views
  • 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.
  • U Offline
    U Offline
    umod.47
    wrote on last edited by umod.47
    #1

    Hello.
    I'm using Qt Creator 4.9.2 in a C++ CMake project, that can be both built as a desktop application and as web assembly for a browser (using Emscripten, emcc). The project relies heavily on modern C++17 features, so I have to use CLang code model in IDE.
    I was able to setup the build process by adding additional compilator and a kit, everything builds just fine.
    However, code completion doesn't seem to work when switching to emcc toolchain.
    I was able to find this guide and look through libclang debug messages:
    https://wiki.qt.io/Qt_Creator_Clang_Code_Model
    Looks like CLangCodeModel catches some ugly emcc-related command line arguments (like --preload-file, -s WASM=1 and so on) and quits with error. I get the following message for every file:

    Parsing <literraly, any file>:   0.0000 (100.0%)   0.0000 (100.0%)   0.0000 (100.0%)  
    Parsing <literraly, any file> failed: CXError_Failure
    

    When I switch to desktop compiler (gcc or clang), I get some output, for example - list of include paths. All autocomplete features work fine.

    Another thing: I have to use emcc with some additional libraries, that is not a part of system, but resides somewhere under /home directory. I have to pass some special environment variables and CMake values like EMSCRIPTEN="/home/..." and CMAKE_TOOLCHAIN_FILE="...". As a result, Code Model misses some obvious headers like <vector> or <memory> (std namespace is completely ignored).

    Is there a way to manipulpate libclang command line arguments?
    How can I understand why it stops with CXError_Failure?
    Can I make it independent of the compiler I use?

    I don't want to switch to another IDE. I've tried sublme text (it uses 6 CPU cores for around 10 minutes to parse source files) and CLion (I'm not familiar with it, and it will require additional time to master).

    Thanks.

    Press ESCAPE to enter or ENTER to escape.
    Keyboard not found. Press F1 to continue.
    (c) BIOS

    1 Reply Last reply
    0
    • H Offline
      H Offline
      HugoH
      wrote on last edited by
      #2

      I got CXError_Failure when libclang couldn't handle one of the compiler arguments in compile_commands.json. See QTCREATORBUG-22063.

      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