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. Error when building RC Object (Application Icon)

Error when building RC Object (Application Icon)

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 1.2k 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.
  • A Offline
    A Offline
    Aadnesid
    wrote on 17 May 2022, 18:51 last edited by
    #1

    Hi, I am currently trying to get an application icon working for my test program. I am using cmake for this.

    I've made a .rc file and tried to follow the steps the guide was telling me to do. Currently I am stuck when building the cmake file which gives me the build error:

    "[2/13 0.5/sec] Building RC object CMakeFiles/Project-2022v.dir/icons.rc.obj
    FAILED: CMakeFiles/Project-2022v.dir/icons.rc.obj

    I've double checked that the icons are relative to the rc file and that the file is reachable. But I am pretty confused as to why the error names the .rc file extension plus a .obj. If that's the cause, how do I fix this?

    Cheers,
    Aadne.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on 17 May 2022, 22:43 last edited by
      #2

      Can you share your CMakeLists file and the compiler output?

      1 Reply Last reply
      0
      • V Offline
        V Offline
        VRonin
        wrote on 17 May 2022, 23:42 last edited by
        #3

        There is nothing special to do, you just need to add the .rc file as you would a .cpp file.
        What is the content of the .rc file?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Aadnesid
          wrote on 18 May 2022, 08:14 last edited by
          #4

          That's what I figured.
          Here is the contents of the .rc file aswell as my directory
          ccb921c5-963c-421c-8647-9e7f92408c6f-image.png

          Here is my cmake file, incase you spot any dumb errors on my part.
          Icons.rc is set under "Project Sources" at the bottom.

          cmake_minimum_required(VERSION 3.5)
          
          project(Project-2022v VERSION 0.1 LANGUAGES CXX)
          
          set(CMAKE_INCLUDE_CURRENT_DIR ON)
          
          set(CMAKE_AUTOUIC ON)
          set(CMAKE_AUTOMOC ON)
          set(CMAKE_AUTORCC ON)
          
          set(CMAKE_CXX_STANDARD 17)
          set(CMAKE_CXX_STANDARD_REQUIRED ON)
          
          if(WIN32)
          find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
          ENDIF()
          
          if(APPLE)
              set(CMAKE_PREFIX_PATH "/Users/zekariamohamed/Qt/6.2.4/macos/lib/cmake")
              find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets)
          ENDIF()
          
          
          find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
          find_package(Qt6 COMPONENTS Sql REQUIRED)
          
          
          
          set(PROJECT_SOURCES
                  #MAIN
                  functions/main/main.cpp
                  functions/main/mainwindow.cpp
                  functions/main/mainwindow.h
                  functions/main/mainwindow.ui
          
                  #ADD
                  functions/add/add_dialog.h
                  functions/add/add_dialog.cpp
                  functions/add/add_dialog.ui
          
                      functions/add/add_dialog_customer.h
                      functions/add/add_dialog_customer.cpp
                      functions/add/add_dialog_customer.ui
          
                      functions/add/add_dialog_car.h
                      functions/add/add_dialog_car.cpp
                      functions/add/add_dialog_car.ui
          
                  #REMOVE
                  functions/remove/remove_dialog.h
                  functions/remove/remove_dialog.cpp
                  functions/remove/remove_dialog.ui
          
                      functions/remove/remove_dialog_car.h
                      functions/remove/remove_dialog_car.cpp
                      functions/remove/remove_dialog_car.ui
          
                      functions/remove/remove_dialog_customer.h
                      functions/remove/remove_dialog_customer.cpp
                      functions/remove/remove_dialog_customer.ui
          
                  #SEARCH
                  functions/search/search_dialog.h
                  functions/search/search_dialog.cpp
                  functions/search/search_dialog.ui
          
                  #ASSIGN
                  functions/assign/assign_car.h
                  functions/assign/assign_car.cpp
                  functions/assign/assign_car.ui
          
                  functions/assign/unassign_car.h
                  functions/assign/unassign_car.cpp
                  functions/assign/unassign_car.ui
          
                  #RESOURCES
                  resources.qrc
                  database/rental.sqlite
                  functions/main/database.h
                  icons.rc
              )
          
          if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
              qt_add_executable(Project-2022v
                  MANUAL_FINALIZATION
                  ${PROJECT_SOURCES}
              )
          # Define target properties for Android with Qt 6 as:
          #    set_property(TARGET Project-2022v APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
          #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
          # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
          else()
              if(ANDROID)
                  add_library(Project-2022v SHARED
                      ${PROJECT_SOURCES}
                  )
          # Define properties for Android with Qt 5 after find_package() calls as:
          #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
              else()
                  add_executable(Project-2022v
                      ${PROJECT_SOURCES}
                  )
              endif()
          endif()
          
          target_link_libraries(Project-2022v PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
          target_link_libraries(Project-2022v PRIVATE Qt6::Sql)
          
          set_target_properties(Project-2022v PROPERTIES
              MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
              MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
              MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
              MACOSX_BUNDLE TRUE
              WIN32_EXECUTABLE FALSE
          )
          
          if(QT_VERSION_MAJOR EQUAL 6)
              qt_finalize_executable(Project-2022v)
          endif()
          
          
          

          And finally, here is my compiler output:

          10:07:28: Running steps for project Project-2022v...
          10:07:28: Starting: "C:\Qtl\Tools\CMake_64\bin\cmake.exe" --build "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug" --target all
          [1/2 1.1/sec] Building RC object CMakeFiles/Project-2022v.dir/icons.rc.obj
          FAILED: CMakeFiles/Project-2022v.dir/icons.rc.obj 
          C:\Qt\Tools\mingw1120_64\bin\windres.exe -O coff -DMINGW_HAS_SECURE_API=1 -DQT_CORE_LIB -DQT_GUI_LIB -DQT_SQL_LIB -DQT_WIDGETS_LIB -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN64 -I "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug" -I "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/Project-2022v" -I "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug/Project-2022v_autogen/include" -I C:/Qt/6.2.4/mingw_64/include/QtCore -I C:/Qt/6.2.4/mingw_64/include -I C:/Qt/6.2.4/mingw_64/mkspecs/win32-g++ -I C:/Qt/6.2.4/mingw_64/include/QtWidgets -I C:/Qt/6.2.4/mingw_64/include/QtGui -I C:/Qt/6.2.4/mingw_64/include/QtSql  "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/Project-2022v/icons.rc" CMakeFiles/Project-2022v.dir/icons.rc.obj
          cc1.exe: fatal error: 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug: No such file or directory
          compilation terminated.
          cc1.exe: fatal error: 2022/Program/Project-2022v: No such file or directory
          compilation terminated.
          cc1.exe: fatal error: 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug/Project-2022v_autogen/include: No such file or directory
          compilation terminated.
          C:\Qt\Tools\mingw1120_64\bin\windres.exe: preprocessing failed.
          ninja: build stopped: subcommand failed.
          10:07:29: The process "C:\Qtl\Tools\CMake_64\bin\cmake.exe" exited with code 1.
          Error while building/deploying project Project-2022v (kit: Desktop Qt 6.2.4 MinGW 64-bit)
          When executing step "Build"
          10:07:29: Elapsed time: 00:01.
          

          Cheers,
          Aadne.

          JonBJ 1 Reply Last reply 18 May 2022, 08:32
          0
          • A Aadnesid
            18 May 2022, 08:14

            That's what I figured.
            Here is the contents of the .rc file aswell as my directory
            ccb921c5-963c-421c-8647-9e7f92408c6f-image.png

            Here is my cmake file, incase you spot any dumb errors on my part.
            Icons.rc is set under "Project Sources" at the bottom.

            cmake_minimum_required(VERSION 3.5)
            
            project(Project-2022v VERSION 0.1 LANGUAGES CXX)
            
            set(CMAKE_INCLUDE_CURRENT_DIR ON)
            
            set(CMAKE_AUTOUIC ON)
            set(CMAKE_AUTOMOC ON)
            set(CMAKE_AUTORCC ON)
            
            set(CMAKE_CXX_STANDARD 17)
            set(CMAKE_CXX_STANDARD_REQUIRED ON)
            
            if(WIN32)
            find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
            ENDIF()
            
            if(APPLE)
                set(CMAKE_PREFIX_PATH "/Users/zekariamohamed/Qt/6.2.4/macos/lib/cmake")
                find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets)
            ENDIF()
            
            
            find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
            find_package(Qt6 COMPONENTS Sql REQUIRED)
            
            
            
            set(PROJECT_SOURCES
                    #MAIN
                    functions/main/main.cpp
                    functions/main/mainwindow.cpp
                    functions/main/mainwindow.h
                    functions/main/mainwindow.ui
            
                    #ADD
                    functions/add/add_dialog.h
                    functions/add/add_dialog.cpp
                    functions/add/add_dialog.ui
            
                        functions/add/add_dialog_customer.h
                        functions/add/add_dialog_customer.cpp
                        functions/add/add_dialog_customer.ui
            
                        functions/add/add_dialog_car.h
                        functions/add/add_dialog_car.cpp
                        functions/add/add_dialog_car.ui
            
                    #REMOVE
                    functions/remove/remove_dialog.h
                    functions/remove/remove_dialog.cpp
                    functions/remove/remove_dialog.ui
            
                        functions/remove/remove_dialog_car.h
                        functions/remove/remove_dialog_car.cpp
                        functions/remove/remove_dialog_car.ui
            
                        functions/remove/remove_dialog_customer.h
                        functions/remove/remove_dialog_customer.cpp
                        functions/remove/remove_dialog_customer.ui
            
                    #SEARCH
                    functions/search/search_dialog.h
                    functions/search/search_dialog.cpp
                    functions/search/search_dialog.ui
            
                    #ASSIGN
                    functions/assign/assign_car.h
                    functions/assign/assign_car.cpp
                    functions/assign/assign_car.ui
            
                    functions/assign/unassign_car.h
                    functions/assign/unassign_car.cpp
                    functions/assign/unassign_car.ui
            
                    #RESOURCES
                    resources.qrc
                    database/rental.sqlite
                    functions/main/database.h
                    icons.rc
                )
            
            if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
                qt_add_executable(Project-2022v
                    MANUAL_FINALIZATION
                    ${PROJECT_SOURCES}
                )
            # Define target properties for Android with Qt 6 as:
            #    set_property(TARGET Project-2022v APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
            #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
            # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
            else()
                if(ANDROID)
                    add_library(Project-2022v SHARED
                        ${PROJECT_SOURCES}
                    )
            # Define properties for Android with Qt 5 after find_package() calls as:
            #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
                else()
                    add_executable(Project-2022v
                        ${PROJECT_SOURCES}
                    )
                endif()
            endif()
            
            target_link_libraries(Project-2022v PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
            target_link_libraries(Project-2022v PRIVATE Qt6::Sql)
            
            set_target_properties(Project-2022v PROPERTIES
                MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
                MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
                MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
                MACOSX_BUNDLE TRUE
                WIN32_EXECUTABLE FALSE
            )
            
            if(QT_VERSION_MAJOR EQUAL 6)
                qt_finalize_executable(Project-2022v)
            endif()
            
            
            

            And finally, here is my compiler output:

            10:07:28: Running steps for project Project-2022v...
            10:07:28: Starting: "C:\Qtl\Tools\CMake_64\bin\cmake.exe" --build "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug" --target all
            [1/2 1.1/sec] Building RC object CMakeFiles/Project-2022v.dir/icons.rc.obj
            FAILED: CMakeFiles/Project-2022v.dir/icons.rc.obj 
            C:\Qt\Tools\mingw1120_64\bin\windres.exe -O coff -DMINGW_HAS_SECURE_API=1 -DQT_CORE_LIB -DQT_GUI_LIB -DQT_SQL_LIB -DQT_WIDGETS_LIB -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN64 -I "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug" -I "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/Project-2022v" -I "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug/Project-2022v_autogen/include" -I C:/Qt/6.2.4/mingw_64/include/QtCore -I C:/Qt/6.2.4/mingw_64/include -I C:/Qt/6.2.4/mingw_64/mkspecs/win32-g++ -I C:/Qt/6.2.4/mingw_64/include/QtWidgets -I C:/Qt/6.2.4/mingw_64/include/QtGui -I C:/Qt/6.2.4/mingw_64/include/QtSql  "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/Project-2022v/icons.rc" CMakeFiles/Project-2022v.dir/icons.rc.obj
            cc1.exe: fatal error: 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug: No such file or directory
            compilation terminated.
            cc1.exe: fatal error: 2022/Program/Project-2022v: No such file or directory
            compilation terminated.
            cc1.exe: fatal error: 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug/Project-2022v_autogen/include: No such file or directory
            compilation terminated.
            C:\Qt\Tools\mingw1120_64\bin\windres.exe: preprocessing failed.
            ninja: build stopped: subcommand failed.
            10:07:29: The process "C:\Qtl\Tools\CMake_64\bin\cmake.exe" exited with code 1.
            Error while building/deploying project Project-2022v (kit: Desktop Qt 6.2.4 MinGW 64-bit)
            When executing step "Build"
            10:07:29: Elapsed time: 00:01.
            

            Cheers,
            Aadne.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on 18 May 2022, 08:32 last edited by
            #5

            @Aadnesid said in Error when building RC Object (Application Icon):

            C:\Qt\Tools\mingw1120_64\bin\windres.exe -O coff -DMINGW_HAS_SECURE_API=1 -DQT_CORE_LIB -DQT_GUI_LIB -DQT_SQL_LIB -DQT_WIDGETS_LIB -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN64 -I "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug" -I "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/Project-2022v" -I "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug/Project-2022v_autogen/include" -I C:/Qt/6.2.4/mingw_64/include/QtCore -I C:/Qt/6.2.4/mingw_64/include -I C:/Qt/6.2.4/mingw_64/mkspecs/win32-g++ -I C:/Qt/6.2.4/mingw_64/include/QtWidgets -I C:/Qt/6.2.4/mingw_64/include/QtGui -I C:/Qt/6.2.4/mingw_64/include/QtSql  "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/Project-2022v/icons.rc" CMakeFiles/Project-2022v.dir/icons.rc.obj
            
            cc1.exe: fatal error: 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug: No such file or directory
            

            Even though I think it shows quoted ("...") correctly, the error message shows that somewhere it is treating your

            "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/..." 
            

            path as two separate elements, broken at the space inside Prosjektoppgave 2022, hence the 2022/Program/... of the error message.

            Simplest would be not to use a path with a space in it? I think there have been other occasions where Qt builds have problems with path names with spaces like this....

            A 1 Reply Last reply 18 May 2022, 19:11
            3
            • JonBJ JonB
              18 May 2022, 08:32

              @Aadnesid said in Error when building RC Object (Application Icon):

              C:\Qt\Tools\mingw1120_64\bin\windres.exe -O coff -DMINGW_HAS_SECURE_API=1 -DQT_CORE_LIB -DQT_GUI_LIB -DQT_SQL_LIB -DQT_WIDGETS_LIB -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN64 -I "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug" -I "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/Project-2022v" -I "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug/Project-2022v_autogen/include" -I C:/Qt/6.2.4/mingw_64/include/QtCore -I C:/Qt/6.2.4/mingw_64/include -I C:/Qt/6.2.4/mingw_64/mkspecs/win32-g++ -I C:/Qt/6.2.4/mingw_64/include/QtWidgets -I C:/Qt/6.2.4/mingw_64/include/QtGui -I C:/Qt/6.2.4/mingw_64/include/QtSql  "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/Project-2022v/icons.rc" CMakeFiles/Project-2022v.dir/icons.rc.obj
              
              cc1.exe: fatal error: 2022/Program/build-Project-2022v-Desktop_Qt_6_2_4_MinGW_64_bit-Debug: No such file or directory
              

              Even though I think it shows quoted ("...") correctly, the error message shows that somewhere it is treating your

              "C:/Users/aadne/ikt103g22v/assignments/solutions/Prosjektoppgave 2022/Program/..." 
              

              path as two separate elements, broken at the space inside Prosjektoppgave 2022, hence the 2022/Program/... of the error message.

              Simplest would be not to use a path with a space in it? I think there have been other occasions where Qt builds have problems with path names with spaces like this....

              A Offline
              A Offline
              Aadnesid
              wrote on 18 May 2022, 19:11 last edited by
              #6

              @JonB You are totally right in that regard, after replacing that space with a simple "_" (and all the other stuff regarding fixing paths in cmake etc.) it finally works.

              So lesson learned, avoid using spaces and such in file directories.
              Thanks a ton!

              Cheers,
              Aadne.

              1 Reply Last reply
              1

              1/6

              17 May 2022, 18:51

              • Login

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