Error when building RC Object (Application Icon)
-
wrote on 17 May 2022, 18:51 last edited by
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.objI'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. -
wrote on 17 May 2022, 22:43 last edited by
Can you share your CMakeLists file and the compiler output?
-
wrote on 17 May 2022, 23:42 last edited by
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? -
wrote on 18 May 2022, 08:14 last edited by
That's what I figured.
Here is the contents of the .rc file aswell as my directory
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. -
That's what I figured.
Here is the contents of the .rc file aswell as my directory
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.wrote on 18 May 2022, 08:32 last edited by@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 the2022/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....
-
@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 the2022/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....
wrote on 18 May 2022, 19:11 last edited by@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/6