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. configuring for cross development
Forum Updated to NodeBB v4.3 + New Features

configuring for cross development

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
4 Posts 2 Posters 1.1k 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by mzimmers
    #1

    Hi all -

    I've attempted this before, but gave up early. I'd like to return my attention to the effort.

    I'm trying to use Qt Creator as my IDE for a non-Qt project, hosted on an ESP32 device. When I attempt to open the project's CMakeLists.txt file, I get this error:

    C:\.espressif\tools\cmake\3.20.3\share\cmake-3.20\Modules\CMakeTestCCompiler.cmake:66: error: The C compiler "C:/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: C:/repos/iQPump-ESP32/fw/build-main-ESP32-Debug/CMakeFiles/CMakeTmp Run Build Command(s):C:/Qt/Tools/Ninja/ninja.exe cmTC_8a838 && [1/2] Building C object CMakeFiles/cmTC_8a838.dir/testCCompiler.c.obj [2/2] Linking C executable cmTC_8a838.exe FAILED: cmTC_8a838.exe cmd.exe /C "cd . && C:\.espressif\tools\xtensa-esp32-elf\esp-2021r2-patch3-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe   CMakeFiles/cmTC_8a838.dir/testCCompiler.c.obj -o cmTC_8a838.exe -Wl,--out-implib,libcmTC_8a838.dll.a -Wl,--major-image-version,0,--minor-image-version,0   && cd ." c:/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: unrecognized option '--major-image-version' c:/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: use the --help option for usage information collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed.
    

    I'm not sure how to interpret this error message -- is it saying that it's unable to link my project?

    Thanks...

    EDIT: I found my way to a log file, and it contained this error:

    c:/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: unrecognized option '--major-image-version'
    

    It's not clear to me where this option is supposed to be set...any ideas?

    1 Reply Last reply
    0
    • cristian-adamC Offline
      cristian-adamC Offline
      cristian-adam
      wrote on last edited by
      #2

      If you grep after --major-image-version in your CMake installation at C:\.espressif\tools\cmake\3.20.3\share\cmake-3.20\Modules you would get a result in:

      C:\.espressif\tools\cmake\3.20.3\share\cmake-3.20\Modules\Platform\CYGWIN-GNU.cmake 
      C:\.espressif\tools\cmake\3.20.3\share\cmake-3.20\Modules\Platform\Windows-Clang.cmake 
      C:\.espressif\tools\cmake\3.20.3\share\cmake-3.20\Modules\Platform\Windows-GNU.cmake
      

      Windows-GNU.cmake would have something like:

      set(CMAKE_GNULD_IMAGE_VERSION
        "-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>")
      

      As your toolchain linker doesn't support this parameter, you should follow the instruction from https://cmake.org/cmake/help/v3.20/manual/cmake-toolchains.7.html and create a toolchain file for your ... toolchain.

      Or if this is too complicated, can try to set in your project's CMakeLists.txt after the project() call:

      set(CMAKE_GNULD_IMAGE_VERSION "")
      

      But this would make CMake use your gcc as a Windows GCC toolchain, which is not the case.

      Coming back to the toolchain file, apparently the esp-idf github project has something like this

      include($ENV{IDF_PATH}/tools/cmake/utilities.cmake)
      
      set(CMAKE_SYSTEM_NAME Generic)
      
      set(CMAKE_C_COMPILER xtensa-esp32-elf-gcc)
      set(CMAKE_CXX_COMPILER xtensa-esp32-elf-g++)
      set(CMAKE_ASM_COMPILER xtensa-esp32-elf-gcc)
      set(_CMAKE_TOOLCHAIN_PREFIX xtensa-esp32-elf-)
      
      
      remove_duplicated_flags("-mlongcalls -Wno-frame-address ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS)
      set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE)
      remove_duplicated_flags("-mlongcalls -Wno-frame-address ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS)
      set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE)
      

      Which is done in "classic" style and requires set forcing of compiler flags. A better way can be found here https://www.qt.io/blog/standalone-boot2qt-/-yocto-sdk-cmake-toolchain

      mzimmersM 1 Reply Last reply
      1
      • cristian-adamC cristian-adam

        If you grep after --major-image-version in your CMake installation at C:\.espressif\tools\cmake\3.20.3\share\cmake-3.20\Modules you would get a result in:

        C:\.espressif\tools\cmake\3.20.3\share\cmake-3.20\Modules\Platform\CYGWIN-GNU.cmake 
        C:\.espressif\tools\cmake\3.20.3\share\cmake-3.20\Modules\Platform\Windows-Clang.cmake 
        C:\.espressif\tools\cmake\3.20.3\share\cmake-3.20\Modules\Platform\Windows-GNU.cmake
        

        Windows-GNU.cmake would have something like:

        set(CMAKE_GNULD_IMAGE_VERSION
          "-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>")
        

        As your toolchain linker doesn't support this parameter, you should follow the instruction from https://cmake.org/cmake/help/v3.20/manual/cmake-toolchains.7.html and create a toolchain file for your ... toolchain.

        Or if this is too complicated, can try to set in your project's CMakeLists.txt after the project() call:

        set(CMAKE_GNULD_IMAGE_VERSION "")
        

        But this would make CMake use your gcc as a Windows GCC toolchain, which is not the case.

        Coming back to the toolchain file, apparently the esp-idf github project has something like this

        include($ENV{IDF_PATH}/tools/cmake/utilities.cmake)
        
        set(CMAKE_SYSTEM_NAME Generic)
        
        set(CMAKE_C_COMPILER xtensa-esp32-elf-gcc)
        set(CMAKE_CXX_COMPILER xtensa-esp32-elf-g++)
        set(CMAKE_ASM_COMPILER xtensa-esp32-elf-gcc)
        set(_CMAKE_TOOLCHAIN_PREFIX xtensa-esp32-elf-)
        
        
        remove_duplicated_flags("-mlongcalls -Wno-frame-address ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS)
        set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE)
        remove_duplicated_flags("-mlongcalls -Wno-frame-address ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS)
        set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE)
        

        Which is done in "classic" style and requires set forcing of compiler flags. A better way can be found here https://www.qt.io/blog/standalone-boot2qt-/-yocto-sdk-cmake-toolchain

        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        @cristian-adam thank you for the detailed reply. I'm still trying to understand how the CMake process operates, so I have a few more questions, if you don't mind:

        • do I understand correctly that Creator is attempting to use Windows-GNU.cmake in the build? If so, is this correct?

        • you mention a toolchain file. Is this the same as a CMake Source File (as shown in the Windows Explorer window)?

        • if I were to make my own toolchain file, where should it reside? I don't want to modify the contents of the .espressif/tools directory.

        • would you consider this a bug in the Espressif toolchain? If so, I can submit an entry on their github.

        Thank you again.

        cristian-adamC 1 Reply Last reply
        0
        • mzimmersM mzimmers

          @cristian-adam thank you for the detailed reply. I'm still trying to understand how the CMake process operates, so I have a few more questions, if you don't mind:

          • do I understand correctly that Creator is attempting to use Windows-GNU.cmake in the build? If so, is this correct?

          • you mention a toolchain file. Is this the same as a CMake Source File (as shown in the Windows Explorer window)?

          • if I were to make my own toolchain file, where should it reside? I don't want to modify the contents of the .espressif/tools directory.

          • would you consider this a bug in the Espressif toolchain? If so, I can submit an entry on their github.

          Thank you again.

          cristian-adamC Offline
          cristian-adamC Offline
          cristian-adam
          wrote on last edited by
          #4

          @mzimmers said in configuring for cross development:

          @cristian-adam thank you for the detailed reply. I'm still trying to understand how the CMake process operates, so I have a few more questions, if you don't mind:

          • do I understand correctly that Creator is attempting to use Windows-GNU.cmake in the build? If so, is this correct?

          This is what CMake is doing. Qt Creator has nothing to do with it. CMake is receiving a gcc.exe and it looks at the host platform ... Windows so it picks up its Windows-GNU.cmake internal code path and tries the best out of it. Since this is not a MinGW GCC toolchain is bound to fail.

          • you mention a toolchain file. Is this the same as a CMake Source File (as shown in the Windows Explorer window)?

          • if I were to make my own toolchain file, where should it reside? I don't want to modify the contents of the .espressif/tools directory.

          You need a esp.cmake text file, which we would refer as toolchain file, and then in Qt Creator (or commandline) pass the CMAKE_TOOLCHAIN_FILE variable pointing to this file.

          • would you consider this a bug in the Espressif toolchain? If so, I can submit an entry on their github.

          I personally have no interest in the esp toolchain, it's the first time I've heard about it.

          Their toolchain is not buggy, it's just doing extra work and makes it a bit hard to follow, it's not as easy to copy paste, it needs the extra API file (e.g. $ENV{IDF_PATH}/tools/cmake/utilities.cmake), etc.

          But on the other hand you might need to follow their documentation about the CMake support.

          1 Reply Last reply
          1

          • Login

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