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. How can I build project using Clang with QtCreator?
Forum Updated to NodeBB v4.3 + New Features

How can I build project using Clang with QtCreator?

Scheduled Pinned Locked Moved Qt Creator and other tools
6 Posts 3 Posters 23.9k Views 1 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.
  • L Offline
    L Offline
    Latexi95
    wrote on last edited by
    #1

    I would like to build my project with Clang and generate LLVM bitcode. I added Clang toolchain and cloned MinGW's build configuration, but setting toolchain to Clang doesn't seem to affect and project is still build with MinGW. I'm not using Qt libraries.
    What am I doing wrong?

    I'm sorry about bad English.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      Most likely: Nothing.

      I never even assumed that anyone would want to use clang on windows (last time I tried clang could not build anything on windows due to incompatibilities in the headers), so if this works, then it is more or less by accident:-) I am not even sure whether clang is supposed to be compatible with mingw or msvc builds (and which versions of the latter)!

      Possible workarounds: Go to Tools->Options->Build & Run->Tool Chains and set the ABI manually to match the Qt version you want to use. Give it a try, you might need to use a msvc build Qt though for this to work.

      If you want to help to improve the support: Could you please post the output of "clang --dumpmachine" (that is two dashes, the forum messes that up!) as well as the ABI of the Qt version you managed to get to work with clang (hover the Qt version in Tools->Options->Build & Run->Qt Versions to see the ABI). Better yet: Put that information into a bug report and assign it to me. Then I won't forget:-)

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Latexi95
        wrote on last edited by
        #3

        "Clang -dumpmanchine" prints "i686-pc-win32".
        I tried Clang with "Qt 4.8.0 for Desktop - MinGW (QtSDK)" and msvc2010 version. If I change the tool chain of the "Qt 4.8.0 for Desktop - MSVC2010 (QtSDK)" to Clang, it will use mingw32-make and fail because of msvc's incompatible makefile.

        Forcing "Qt 4.8.0 for Desktop - MinGW (QtSDK)" to use Clang adding "QMAKE_CXX = clang++.exe" to projectfile seems to work with a very simple static library but linker will complain about Clang's .o files, if I try to build an application.

        So how could I first compile all sourcefiles in project
        @clang++ -emit-llvm -c file.cpp -o file.bc @

        and then link them
        @llvm-ld -link-as-library file1.bc file2.bc ... @

        Thank you for answers.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on last edited by
          #4

          Try overriding the make command by giving your own. We only fall back to what the tool chain suggests if it is not overridden in Projects->(target)->Build->Make Step.

          I doubt that doing the linking separately will help. most likely the object files are just not compatible with each other.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            Latexi95
            wrote on last edited by
            #5

            Now it seems to work correctly and it produces llvm bitcode files.
            I used mingw32-make and I added these lines to project file:
            @TARGET_EXT = .bc
            QMAKE_EXT_OBJ = .bc
            QMAKE_CXXFLAGS += -emit-llvm
            QMAKE_CXX = clang++
            QMAKE_CC = clang
            QMAKE_LIB = llvm-ld -link-as-library -o
            QMAKE_RUN_CXX = $(CXX) $(CXXFLAGS) $(INCPATH) -c $src -o $obj
            QMAKE_RUN_CC = $(CC) $(CCFLAGS) $(INCPATH) -c $src -o $obj @

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vishu
              wrote on last edited by
              #6

              Hi Latexl95 ,
              How you made it work..? Please can you explain in detail,
              I am using Qt 5.0.2 and windows 7 , and i just downloaded llvm 3.3 and clang 3.3. How can i compile my code with clang and how to generate the bitcode using llvm.

              Thanks

              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