Hi guys,
I am trying to build my first project in ROS and so far I am amazed. But since yesterday I got stuck on a problem with including a separate *.h and *.cpp file. I copied the files in a subdirectory in /src called ThirdParty/brisk and added the include paths to the CMakeLists.txt as you can see below (to #include files with <> instead ot ""). I also build an eclipse project and the auto-completition shows me the classes from the included files, but when i try to build it I get the error "undefined reference" as you can see below! Somehow the compiler does not get the *.cpp file (aka brisk.cpp), but I got no idea what I did wrong!
Probably just one little link/include/cmd is missing!!!
I have read a lot about this "undefined reference" error and to mention that: the file brisk.h and brisk.cpp work well in a "not-ROS" project. So the common mistake of forgetting BriskFeatureDetector::BriskFeatureDetector(...) isn't the problem here!
I hope you cam help!!
thx!
CMakeLists.txt
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
include_directories(/home/me/topological_map/topological_map_v1/src/ThirdParty/brisk)
# 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()
#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)
#uncomment if you have defined messages
rosbuild_genmsg()
rosbuild_add_executable(ImgProcEngineNode src/ros_src/rosImgProcEngine.cpp)
rosbuild_add_compile_flags(ImgProcEngineNode "-c -fmessage-length=0
-march=native -msse2 -msse3 -mssse3 -I/home/me/topological_map/topological_map_v1/src/ThirdParty/brisk
-I/home/me/topological_map/topological_map_v1/src/ThirdParty/brisk/agast")
manifest.xml
<package>
<description brief="topological_map_v1">
topological_map_v1
</description>
<author>me</author>
<license>BSD</license>
<review status="unreviewed" notes=""/>
<url>http://ros.org/wiki/topological_map_v1</url>
<depend package="opencv2"/>
<depend package="sensor_msgs"/>
<depend package="rospy"/>
<depend package="roscpp"/>
<export>
<cpp cflags="-msse2 -msse3 -mssse3 -I/ThirdParty/brisk -I/ThirdParty/brisk/agast"/>
<intel_cpp cflags="-msse2 -msse3 -mssse3"/>
</export>
</package>
rosImgProcEngine.cpp
#include "ros/ros.h"
#include "std_msgs/String.h"
#include "topological_map_v1/rosImageIn.h"
#include <boost/shared_ptr.hpp>
#include <opencv/cv.h>
#include <opencv/ml.h>
#include <opencv2/core/core.hpp>
#include <opencv2/core/mat.hpp>
#include <opencv2/core/operations.hpp>
#include <opencv2/nonfree/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <brisk.h>
#include <iostream>
#include <vector>
#include <sstream>
using namespace std;
using namespace cv;
int main(int argc, char **argv)
{
ros::init(argc, argv, "talker");
ros::NodeHandle n;
Ptr<FeatureDetector> _detector = new BriskFeatureDetector(90,4);
Ptr<DescriptorExtractor> _extractor = new BriskDescriptorExtractor(false);
...
}
Console Output after "make"
...
CMakeFiles/ImgProcEngineNode.dir/src/ros_src/rosImgProcEngine.o: In function `main':
/home/me/topological_map/topological_map_v1/src/ros_src/rosImgProcEngine.cpp:31: undefined reference to `cv::BriskFeatureDetector::BriskFeatureDetector(int, int)'
/home/me/topological_map/topological_map_v1/src/ros_src/rosImgProcEngine.cpp:32: undefined reference to `cv::BriskDescriptorExtractor::BriskDescriptorExtractor(bool, bool, float)'
collect2: ld returned 1 exit status
make[2]: *** [bin/ImgProcEngineNode] Error 1
make[1]: *** [CMakeFiles/ImgProcEngineNode.dir/all] Error 2
make: *** [all] Error 2
Originally posted by MiseryInDevice on ROS Answers with karma: 31 on 2012-09-30
Post score: 0