Undefined reference to `cv::VideoCapture::~VideoCapture()
Hi all ! I want compile the package bebop_teleop but it gives the error that:
WebcamPublisher.cpp:(.text+0x7d4): undefined reference to `cv::VideoCapture::~VideoCapture()
I already installed ffmpeg, because someone mentioned that its needed to be installed. I searched the problem on different forums but they used other platforms not CATKIN and ROS if someone has faced this problem using ROS, please help me. Thanks alot. my source code is:
#include <cv_bridge/cv_bridge.h>
#include <image_transport/image_transport.h>
#include <opencv2/highgui/highgui.hpp>
#include <ros/ros.h>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include "opencv2/core/core.hpp"
#include "opencv2/opencv.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/video.hpp"
#include "opencv2/imgproc.hpp"
using namespace std;
using namespace cv;
int main(int argc, char** argv) {
ros::init(argc, argv, "webcam_publisher");
ros::NodeHandle nh;
image_transport::ImageTransport it(nh);
image_transport::Publisher pub = it.advertise("bebop/image_raw", 1);
cv::VideoCapture capture(0);
if( !capture.isOpened() ) {
ROS_ERROR("FAILED TO OPEN CAPTURE");
return -1;
}
cv::Mat input;
cv::Mat output;
cv::Size size(640, 368);
sensor_msgs::ImagePtr msg;
ros::Rate r(10);
while( nh.ok() ) {
capture >> input;
if( !input.empty() ) {
cv::resize(input, output, size);
msg = cv_bridge::CvImage(std_msgs::Header(), "bgr8", output).toImageMsg();
pub.publish(msg);
}
ros::spinOnce();
r.sleep();
}
pub.shutdown();
ros::shutdown();
}
cmake_minimum_required(VERSION 3.0.0) project(bebop_teleop)
add_definitions(-std=c++11) add_compile_options(-std=gnu++11)
find_package(catkin REQUIRED COMPONENTS geometry_msgs roscpp std_msgs sensor_msgs bebop_msgs cv_bridge image_transport )
include(FindPkgConfig) pkg_check_modules(SDL2 REQUIRED sdl2) pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf)
#generate_messages(
# DEPENDENCIES
# geometry_msgs
# std_msgs
# sensor_msgs
# bebop_msgs
#)
catkin_package( INCLUDE_DIRS include LIBRARIES bebop_teleop CATKIN_DEPENDS geometry_msgs roscpp std_msgs sensor_msgs bebop_msgs cv_bridge image_transport DEPENDS ${SDL2_LIBRARY} ${SDL2_TTF_LIBRARY} )
include_directories(include ${SDL2_INCLUDE_DIRS} ${SDL2_TTF_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
link_directories(${SDL2_LIBRARY_DIRS} ${SDL2_TTF_LIBRARY_DIRS} ${catkin_LIBRARY_DIRS})
add_executable( bebop_teleop src/Events.cpp src/Input.cpp src/Window.cpp src/ManualControl.cpp src/GUI.cpp src/StateTracker.cpp src/Patroller.cpp src/main.cpp) add_executable( webcam src/WebcamPublisher.cpp) target_link_libraries( bebop_teleop ${SDL2_LIBRARIES} ${SDL2_TTF_LIBRARIES} ${catkin_LIBRARIES} )
target_link_libraries( webcam ${catkin_LIBRARIES} )
have you seen this?
@aPonza yes I already checked that link, and I included those libraries mentioned by him but doesnt work in my case. But in that post I didnt understand one sentence that Some LD_LIBRARY_PATH may solve it. What does this mean may be this solve my problem but I cant get its meaning?
can you please explain ? Thanks alot
Try first to remove
using namespace std
andusing namespace cv
: you're not even using anything fromstd
, and you're qualifying all yourcv
names. Also maybe edit your post to include the CMakeLists.txt which should be the real problemI removed them and still the same error, by the way I didnt include
std
but it was already there when downloaded this package.@aPonza can you please have a look now, I added the contents of CMakeLists.txt file. thanks
You only mention installing ffmpeg, but you link to SDL2 and SDL2_TTF... Do you have those installed?
yes I installed them according to the instructions given here. link text
Have you solved it? Can you please share how?