RQT : .moc file not found
Hello, I'm trying to compile a gui application that interfaces with ROS. This application has in turn to deal with QML itself and therefore has to use QT MOC system. I'm sure it's a silly mistake but as I've a deadline coming soon, I can't afford spending too much time on it.
##############################################################################
# CMake
##############################################################################
cmake_minimum_required(VERSION 2.8.0)
project(gui)
set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")
set(CMAKE_AUTOMOC ON)
#rosbuild_prepare_qt4(QtCore QtGui)
#ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
##############################################################################
# Catkin
##############################################################################
# qt_build provides the qt cmake glue, roscpp the comms for a default talker
find_package(catkin REQUIRED COMPONENTS
qt_build
roscpp
hk_msgs
image_transport
ros_video_components)
set(QML_IMPORT_PATH "${QML_IMPORT_PATH};${CATKIN_GLOBAL_LIB_DESTINATION}" )
set(QML_IMPORT_PATH2 "${QML_IMPORT_PATH};${CATKIN_GLOBAL_LIB_DESTINATION}" )
include_directories(${catkin_INCLUDE_DIRS})
# Use this to define what the package will export (e.g. libs, headers).
# Since the default here is to produce only a binary, we don't worry about
# exporting anything.
## Generate messages in the 'msg' folder
# add_message_files(
# FILES
# )
## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )
## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )
## Generate added messages and services with any dependencies listed here
# generate_messages(
# DEPENDENCIES
# std_msgs # Or other packages containing msgs
# )
catkin_package(
CATKIN_DEPENDS message_runtime)
catkin_package(
LIBRARIES ${PROJECT_NAME}
)
##############################################################################
# Qt Environment
##############################################################################
# this comes from qt_build's qt-ros.cmake which is automatically
# included via the dependency ca ll in package.xml
#rosbuild_prepare_qt4(QtCore QtGui QtQml QtQuick) # Add the appropriate components to the component list here
find_package(Qt5 COMPONENTS Core Gui Qml Quick REQUIRED)
##############################################################################
# Sections
##############################################################################
file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/gui/*.hpp)
QT5_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
QT5_WRAP_CPP(QT_MOC_HPP ${QT_MOC})
##############################################################################
# Sources
##############################################################################
file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)
##############################################################################
# Binaries
##############################################################################
add_executable(gui ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
qt5_use_modules(gui Quick Core)
target_link_libraries(gui ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY} ${catkin_LIBRARIES})
target_include_directories(gui PUBLIC include)
install(TARGETS gui RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
And here is my class definition that requires the MOC system :
class ColorZones : public QObject
{
Q_OBJECT
Q_PROPERTY(QColor zone READ getZoneColor WRITE setZoneColor NOTIFY zoneColorChanged)
public:
explicit ColorZones(QObject *parent = nullptr);
QColor getZoneColor(const int zone) const {return _zonesColor[zone];};
void setZoneColor(const int,const Proximity);
signals:
void zoneColorChanged();
private:
boost::array<QColor,6> _zonesColor;
};
And the QML snippet :
Canvas {
id:canvas
anchors.fill: parent
onPaint:{
var ctx = canvas.getContext('2d');
ctx.lineWidth = 2
ctx.strokeStyle = "black"
//ZONE 0
ctx.fillStyle = ColorZones.getZoneColor(0)
ctx.beginPath()
ctx.moveTo(310,301)
ctx.arcTo(10,1,600,600,65,50)
ctx.closeSubpath()
ctx.beginPath()
ctx.moveTo(310,181);
ctx.lineTo(310,301);
ctx.closeSubpath();
ctx.fill()
ctx.stroke()
}
}
Connections {
target: onZoneColorChanged
onColorChanged: canvas.requestPaint()
}
For now, I got this error message :
fatal error: guiMain.moc: No such file or directory compilation terminated. gui/CMakeFiles/gui.dir/build.make:98: recipe for target 'gui/CMakeFiles/gui.dir/src/guiMain.cpp.o' failed make[2]: *** [gui/CMakeFiles/gui.dir/src/guiMain.cpp.o] Error 1 CMakeFiles/Makefile2:2110:
However, when I inspect the build gui directory, the guiMain.moc is present. What am I suppose to do ? Thanks.
recipe for target 'gui/CMakeFiles/gui.dir/all' failed make[1]: *** [gui/CMakeFiles/gui.dir/all] Error 2 Makefile:138: recipe for target 'all' failed make: *** [all] Error 2
Asked by ta on 2017-12-07 04:34:07 UTC
Comments