# How to add qrc (resource) folder on CMAKE for catkin workspace

I have been trying to include in my CMAKE file a resource folder. Contrarily to a typical folder, this is a catkin_ws, and that is why I am having a bit of difficulties: Project compiles but when I launch the GUI, there are no icons, which means that catkin does not see correctly the resource folder:

Belwo is my CMAKE file:

cmake_minimum_required(VERSION 2.8.3)
project(project)
find_package(catkin REQUIRED COMPONENTS
roscpp
pcl_conversions
pcl_ros
std_msgs
lidar_boat_detection
rviz
)

###
### QT
###
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(Qt5Widgets REQUIRED)
find_package(Qt5PrintSupport)
#find all the qt UI stuff
file(GLOB UI
"src/filterPCDInterface/*.ui"
)

qt5_wrap_ui (MB_UI_HDRS  ${UI}) # Generate resources qt5_add_resources(RESOURCES_RCC${RESOURCE})

include_directories(include ${catkin_INCLUDE_DIRS}) file(GLOB SRCS "src/filterPCDInterface/*.h" "src/filterPCDInterface/*.cpp" "src/filterPCDInterface/*.hpp" ) file(GLOB QT_SRCS "src/filterPCDInterface/*.h" "src/filterPCDInterface/*.cpp" "src/filterPCDInterface/*.hpp" ) ## Declare a catkin package catkin_package() add_executable(filterpcdinterface${MB_UI_HDRS} ${QT_SRCS}${SRCS} ${RESOURCE}) target_link_libraries(filterpcdinterface Qt5::Widgets Qt5::PrintSupport Qt5::Core${catkin_LIBRARIES} ${PCL_LIBRARIES} )  My res.qrc is the one below: <RCC> <qresource prefix="/icons"> <file>down-arrow.png</file> <file>leftArrow.png</file> <file>rightArrow.png</file> <file>uoArrow.png</file> </qresource> </RCC>  Also below is a print screen of my resource file: Below also how my node folder. In order to get to the icons the path is src/folderA/qrc/icons.png What I have done so far: 1) I found a very useful source that really helped to set almost all the project and the related catkin_ws. I also followed what was said in the post but still catkin_make does not see the resource file. It compiles but when I launch the GUI, there are no icons. 2) Also I came across this additional source which was useful but still not able to solve the problem I have. Please point to the right direction to solve this issue. edit retag close merge delete ## Comments Did you found the solution? ( 2021-08-11 04:55:21 -0600 )edit ## 1 Answer Sort by » oldest newest most voted Hello there, I found the solution of your question. file(GLOB QT_RESOURCES RELATIVE${CMAKE_CURRENT_SOURCE_DIR} resources.qrc)


You need to this line just above qt5_add_resources(RESOURCES_RCC \${RESOURCE}) in your CMake file. You also need to put your resource folder into the main directory. For example: src/work_project/<resource folder> I hope you will be able to fix the problem with this.

I think every other code is perfect. I have tried it myself.

if you have any questions feel free to drop comment.

more