Qbs ("Cubes")
  1. Qbs ("Cubes")
  2. QBS-709

"Module cpp could not be loaded" when using ARM GCC toolchain on Windows

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Not Evaluated Not Evaluated
    • Resolution: Done
    • Affects Version/s: 1.3.3
    • Fix Version/s: 1.4.1
    • Labels:
      None
    • Environment:
    • Commits:
      8176a4d4196c9eceed6cc71b4dbdecd16a0aa2e8

      Description

      When try to cross-compile a project based on ARM GCC toolchain on Windows host, got a following error:

      C:\Qt\qtcreator-3.2.82\share\qtcreator\qbs\share\qbs\imports\qbs\base\CppApplication.qbs:4: error: Module cpp could not be loaded.

      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        Hide
        Denis Shienkov added a comment -

        UPL: A workaround - it is to modify a condition in the: qtcreator-3.2.82\share\qtcreator\qbs\share\qbs\modules\cpp\genericunix-gcc.qbs file, e.g. to:

        UnixGCC {
            condition: qbs.targetOS.contains('windows') && qbs.toolchain.contains('gcc')
        }
        
        Show
        Denis Shienkov added a comment - UPL: A workaround - it is to modify a condition in the: qtcreator-3.2.82\share\qtcreator\qbs\share\qbs\modules\cpp\genericunix-gcc.qbs file, e.g. to: UnixGCC { condition: qbs.targetOS.contains('windows') && qbs.toolchain.contains('gcc') }
        Hide
        Ivan added a comment -

        Works! Thank you, Denis Shienkov.
        I found only this one solution in the web.

        Show
        Ivan added a comment - Works! Thank you, Denis Shienkov. I found only this one solution in the web.
        Hide
        Christian Kandeler added a comment -

        Ok, so this is a GCC with a Windows target, that is it produces .exe and .dll files and so on? What are the major differences to mingw?

        Show
        Christian Kandeler added a comment - Ok, so this is a GCC with a Windows target, that is it produces .exe and .dll files and so on? What are the major differences to mingw?
        Hide
        Denis Shienkov added a comment - - edited

        > Ok, so this is a GCC with a Windows target, that is it produces .exe and .dll files and so on?

        Ideally, it is gcc with a target which has not an OS. It is strange that "qbs.targetOS.contains('windows')" is works. I simply tried it "unintentionally" and it is earned by miracle on Windows host with gcc toolchain. This produced just an ELF file (as I think), similar with Linux format.

        > What are the major differences to mingw?

        I don't know. But if I try to change the GCC toolchain to MinGW, then it does not compiled a project. Occurred an error, related to "unknown" argument in command line (I not remember now what exactly is argument that do not like by gcc compiler).

        UPD:

        > it is gcc with a target which has not an OS.

        Though, it is a special case with a BareMetal devices (without OS). In a common case shall be so: hostOS = Windows, targetOS = Linux (or no OS).

        Show
        Denis Shienkov added a comment - - edited > Ok, so this is a GCC with a Windows target, that is it produces .exe and .dll files and so on? Ideally, it is gcc with a target which has not an OS. It is strange that "qbs.targetOS.contains('windows')" is works. I simply tried it "unintentionally" and it is earned by miracle on Windows host with gcc toolchain. This produced just an ELF file (as I think), similar with Linux format. > What are the major differences to mingw? I don't know. But if I try to change the GCC toolchain to MinGW, then it does not compiled a project. Occurred an error, related to "unknown" argument in command line (I not remember now what exactly is argument that do not like by gcc compiler). UPD: > it is gcc with a target which has not an OS. Though, it is a special case with a BareMetal devices (without OS). In a common case shall be so: hostOS = Windows, targetOS = Linux (or no OS).
        Hide
        Tim added a comment -

        I still get this issue with the latest Qt Creator 3.4.0 beta 1.

        Show
        Tim added a comment - I still get this issue with the latest Qt Creator 3.4.0 beta 1.
        Hide
        Tim added a comment - - edited

        TL;DR: A better fix is to change the ABI of your ARM compiler in the Build & Run settings to arm-unix-generic-unknown-32bit. The important bit is the "unix".

        Ok so I did some investigating and have found the following:

        1. The qbs.toolchain value depends only on the "Type" of your selected compiler (in the kits setup). For the MingW type it is "mingw,gcc"; for the GCC type it is just "gcc".
        2. If you really are using MingW to build a normal Windows exe, you don't want to use UnixGCC. Although it does compile, the compilation process freezes if it has to copy any files for installation, and when you try to run the program it doesn't realise it has a .exe extension and says that it can't find it.
        3. The qbs.targetOS value is "windows", *unless you select something other than "unknown" in the second ABI dropdown of the compiler config.

        Therefore a very hacky solution might be this:

        UnixGCC {
            condition: qbs.targetOS.contains('unix')
                    && !qbs.targetOS.contains('darwin') && !qbs.targetOS.contains('linux')  // ### HACK
                    && qbs.toolchain.contains('gcc')
        			|| (qbs.targetOS.contains('windows') && qbs.toolchain.contains('gcc') && !qbs.toolchain.contains('mingw')) // ### Even bigger hack
        }
        

        However a better solution is to just change the ABI of the ARM compiler to "Unix". Then you don't need to modify any files.

        There should really be a nicer error message for this.

        Show
        Tim added a comment - - edited TL;DR: A better fix is to change the ABI of your ARM compiler in the Build & Run settings to arm-unix-generic-unknown-32bit. The important bit is the "unix". Ok so I did some investigating and have found the following: 1. The qbs.toolchain value depends only on the "Type" of your selected compiler (in the kits setup). For the MingW type it is "mingw,gcc"; for the GCC type it is just "gcc". 2. If you really are using MingW to build a normal Windows exe, you don't want to use UnixGCC. Although it does compile, the compilation process freezes if it has to copy any files for installation, and when you try to run the program it doesn't realise it has a .exe extension and says that it can't find it. 3. The qbs.targetOS value is "windows", *unless you select something other than "unknown" in the second ABI dropdown of the compiler config. Therefore a very hacky solution might be this: UnixGCC { condition: qbs.targetOS.contains('unix') && !qbs.targetOS.contains('darwin') && !qbs.targetOS.contains('linux') // ### HACK && qbs.toolchain.contains('gcc') || (qbs.targetOS.contains('windows') && qbs.toolchain.contains('gcc') && !qbs.toolchain.contains('mingw')) // ### Even bigger hack } However a better solution is to just change the ABI of the ARM compiler to "Unix". Then you don't need to modify any files. There should really be a nicer error message for this.
        Hide
        Tim Sander added a comment -

        What about this solution. The idea is that generic gcc is a fallback so the condition is a negative list where better solutions exist?

        import qbs 1.0

        UnixGCC

        { condition: !qbs.targetOS.contains('mingw') && !qbs.targetOS.contains('darwin') && !qbs.targetOS.contains('linux') // ### HACK && qbs.toolchain.contains('gcc') }
        Show
        Tim Sander added a comment - What about this solution. The idea is that generic gcc is a fallback so the condition is a negative list where better solutions exist? import qbs 1.0 UnixGCC { condition: !qbs.targetOS.contains('mingw') && !qbs.targetOS.contains('darwin') && !qbs.targetOS.contains('linux') // ### HACK && qbs.toolchain.contains('gcc') }
        Hide
        cipri added a comment -

        with the latest update of qt creator (4.1) , this problem with "Module cpp could not be loaded" appears again.

        Show
        cipri added a comment - with the latest update of qt creator (4.1) , this problem with "Module cpp could not be loaded" appears again.
        Hide
        Tim added a comment -

        Yeah and even worse, now Qt Creator will keep resetting the compiler ABI in the kit configuration.

        Show
        Tim added a comment - Yeah and even worse, now Qt Creator will keep resetting the compiler ABI in the kit configuration.

          People

          • Assignee:
            Christian Kandeler
            Reporter:
            Denis Shienkov
          • Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes