ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

mysql connection

asked 2013-12-15 23:46:00 -0500

robertjacobs gravatar image

updated 2014-04-20 14:09:34 -0500

ngrennan gravatar image

Hello,

I am trying to establish a mysql database connection within a ROS package. I have found the following two questions;

  • answers.ros.org/questions/32520/add-mysql-to-a-ros-project
  • answers.ros.org/questions/34308/mysql-and-ros

In regards to the first question, I have done everything as said. libmysqlclient15-dev is installed, but still getting the error below. What have I done wrong?

======Error

mkdir -p bin
cd build && cmake -Wdev -DCMAKE_TOOLCHAIN_FILE=/opt/ros/hydro/share/ros/core/rosbuild/rostoolchain.cmake  ..
[rosbuild] Building package zuros_sequencer
-- Using CATKIN_DEVEL_PREFIX: /home/robot/git/zuros/zuros_sequencer/build/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/hydro
-- This workspace overlays: /opt/ros/hydro
-- Using Debian Python package layout
-- Using CATKIN_ENABLE_TESTING: ON
-- Skip enable_testing() for dry packages
-- Using CATKIN_TEST_RESULTS_DIR: /home/robot/git/zuros/zuros_sequencer/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- catkin 0.5.77
[rosbuild] Including /opt/ros/hydro/share/roslisp/rosbuild/roslisp.cmake
[rosbuild] Including /opt/ros/hydro/share/roscpp/rosbuild/roscpp.cmake
[rosbuild] Including /opt/ros/hydro/share/rospy/rosbuild/rospy.cmake
CMake Error at CMakeLists.txt:23 (find_package):
  Could not find module FindMySql.cmake or a configuration file for package
  MySql.

  Adjust CMAKE_MODULE_PATH to find FindMySql.cmake or set MySql_DIR to the
  directory containing a CMake configuration file for MySql.  The file will
  have one of the following names:

    MySqlConfig.cmake
    mysql-config.cmake



-- Configuring incomplete, errors occurred!
make: *** [all] Error 1

======Cmakelists.txt

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)

rosbuild_init()

# add include search paths
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/ros/include
${PROJECT_SOURCE_DIR}/common/include)

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

find_package(MySql REQUIRED)
include_directories(${MYSQL_INCLUDE_DIRS})
add_definitions(${MYSQL_DEFINITIONS})

#uncomment if you have defined messages
#rosbuild_genmsg()
#uncomment if you have defined services
#rosbuild_gensrv()

#common commands for building c++ executables and libraries
#rosbuild_add_library(${PROJECT_NAME} src/example.cpp)
#target_link_libraries(${PROJECT_NAME} another_library)
#rosbuild_add_boost_directories()
#rosbuild_link_boost(${PROJECT_NAME} thread)
#rosbuild_add_executable(example examples/example.cpp)
#target_link_libraries(example ${PROJECT_NAME})

# add build commands
rosbuild_add_executable(sequence ros/src/sequence.cpp
                 ros/src/zwaveSubscriber.cpp
                 ros/src/databaseConnector.cpp)

======manifest.xml

<package>
  <description brief="zuros_sequencer">

     zuros_sequencer

  </description>
  <author>robot</author>
  <license>BSD</license>
  <review status="unreviewed" notes=""/>
  <url>XXX</url>
  <depend package="std_msgs"/>
  <depend package="rospy"/>
  <depend package="roscpp"/>
  <depend package="zuros_sensors"/>
  <rosdep name="libmysqlclient-dev"/>
  <export>
    <cpp lflags="-lmysqlclient"/>
  </export>
</package>
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-03-06 04:33:38 -0500

You should add a directory named "cmake-modules" to your project. Inside this directory, create a file with the name "Findmysqlclient.cmake" and copy this content on it: http://www.cmake.org/Wiki/CMakeUserFi... .

Then, change your CMakeLists.txt. Replace find_package(MySql REQUIRED) for find_package(mysqlclient REQUIRED)

Hope it helps!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-12-15 23:46:00 -0500

Seen: 1,406 times

Last updated: Mar 06 '15