Using the MySQL database in ROS
I tried to use the MYSQL database in ROS like this example but it doesn't work:
1. package.xml
<?xml version="1.0"?>
<package>
<name>teste</name>
<version>1.0.0</version>
<description>The teste package</description>
<maintainer email="joao@todo.todo">joao</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend >
<build_depend>std_msgs</build_depend >
<build_depend>cmake_modules</build_depend>
<build_depend>libmysqlclient-dev</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend >
<run_depend>std_msgs</run_depend >
<run_depend>cmake_modules</run_depend>
<run_depend>libmysqlclient-dev</run_depend>
<export>
<cpp lflags="-lmysqlclient"/>
</export>
</package>
2. CMakeList.txt
cmake_minimum_required(VERSION 2.8.3)
project(teste)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake-modules)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
MySqlClient REQUIRED
)
catkin_package(
)
include_directories(
${catkin_INCLUDE_DIRS}
${MYSQL_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}_node ${catkin_LIBRARIES} ${MYSQL_LIBRARIES} )
3. *The file "FindMySqlClient.cmake" in the folder "cmake-modules"*
IF (MYSQL_INCLUDE_DIR)
SET(MYSQL_FIND_QUIETLY TRUE)
ENDIF (MYSQL_INCLUDE_DIR)
FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
/usr/local/include/mysql
/usr/include/mysql
)
SET(MYSQL_NAMES mysqlclient mysqlclient_r)
FIND_LIBRARY(MYSQL_LIBRARY
NAMES ${MYSQL_NAMES}
PATHS /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu/
PATH_SUFFIXES mysql
)
IF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
SET(MYSQL_FOUND TRUE)
SET( MYSQL_LIBRARIES ${MYSQL_LIBRARY} )
ELSE (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
SET(MYSQL_FOUND FALSE)
SET( MYSQL_LIBRARIES )
ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
IF (MYSQL_FOUND)
IF (NOT MYSQL_FIND_QUIETLY)
MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARY}")
ENDIF (NOT MYSQL_FIND_QUIETLY)
ELSE (MYSQL_FOUND)
IF (MYSQL_FIND_REQUIRED)
MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.")
MESSAGE(FATAL_ERROR "Could NOT find MySQL library")
ENDIF (MYSQL_FIND_REQUIRED)
ENDIF (MYSQL_FOUND)
MARK_AS_ADVANCED(
MYSQL_LIBRARY
MYSQL_INCLUDE_DIR
)
message error:
-- Could not find the required component 'MySqlClient'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by "MySqlClient" with
any of the following names:
MySqlClientConfig.cmake
mysqlclient-config.cmake
Just to check have you tried this?