g2o doesn't find its own functions in ROS
Hello everyone.
I designed a ROS package that needs g2o library for SLAM.
I first tried to download and install it via shell, then I tried, as a test, to make some inclusions:
#include "/opt/ros/fuerte/include/g2o/types/slam2d/vertex_se2.h"
#include "/opt/ros/fuerte/include/g2o/types/slam2d/vertex_point_xy.h"
#include "/opt/ros/fuerte/include/g2o/types/slam2d/edge_se2.h"
#include "/opt/ros/fuerte/include/g2o/types/slam2d/edge_se2_pointxy.h"
#include "/opt/ros/fuerte/include/g2o/types/slam2d/types_slam2d.h"
#include "/opt/ros/fuerte/include/g2o/core/sparse_optimizer.h"
#include "/opt/ros/fuerte/include/g2o/core/block_solver.h"
#include "/opt/ros/fuerte/include/g2o/core/factory.h"
#include "/opt/ros/fuerte/include/g2o/core/optimization_algorithm_factory.h"
#include "/opt/ros/fuerte/include/g2o/core/optimization_algorithm_gauss_newton.h"
#include "/opt/ros/fuerte/include/g2o/solvers/csparse/linear_solver_csparse.h"
rosmake built without any issue the package, even when I added
using namespace g2o;
Then, I added a line of code that I actually need:
SparseOptimizer optimizer;
It gave origin to this error:
CMakeFiles/thesis_main.dir/src/messageListener.o: In function `messageListener':
/home/ubisum/fuerte_workspace/thesis_pack/src/messageListener.cpp:36: undefined reference to `g2o::SparseOptimizer::SparseOptimizer()'
CMakeFiles/thesis_main.dir/src/thesis_main.o: In function `~messageListener':
/home/ubisum/fuerte_workspace/thesis_pack/src/messageListener.h:44: undefined reference to `g2o::SparseOptimizer::~SparseOptimizer()'
As a second attempt, I downloaded vslam package from web, entered its subfolder /g2o and from inside it I ran build.
As a consequence, ROS found a new package g2o, as shown by rospack list; then I updated the manifest file in my package:
<package>
<description brief="thesis_pack">
thesis_pack
</description>
<author>Biagio</author>
<license>BSD</license>
<review status="unreviewed" notes=""/>
<url>http://ros.org/wiki/thesis_pack</url>
<depend package="roscpp"/>
<depend package="rospy"/>
<depend package="tf"/>
<depend package="nav_msgs"/>
<depend package="g2o"/>
</package>
leaving inclusions and g2o's namespace declaration in my .cpp file, but the error continues to remain. Do you know how to solve the problem?
thanks for help