Robotics StackExchange | Archived questions

How do i solve this undefined reference? using opencv code for object recognition via colour to use in rviz

I'm new to Ubuntu so i'm not sure on how to some various problems. Please advise me thanks.

####
#### Running command: "make cmake_check_build_system" in "/home/chiongsterx/catkin_ws/build"
####
####
#### Running command: "make -j1 -l1" in "/home/chiongsterx/catkin_ws/build"
####
Linking CXX executable /home/chiongsterx/catkin_ws/devel/lib/vision/vision1
CMakeFiles/vision1.dir/src/vision.cpp.o: In function `main':
vision.cpp:(.text+0x4c): undefined reference to `cv::VideoCapture::VideoCapture(int)'
vision.cpp:(.text+0x5a): undefined reference to `cv::VideoCapture::isOpened() const'
vision.cpp:(.text+0xc7): undefined reference to `cv::namedWindow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
vision.cpp:(.text+0x132): undefined reference to `cvCreateTrackbar'
vision.cpp:(.text+0x15d): undefined reference to `cvCreateTrackbar'
vision.cpp:(.text+0x188): undefined reference to `cvCreateTrackbar'
vision.cpp:(.text+0x1b3): undefined reference to `cvCreateTrackbar'
vision.cpp:(.text+0x1de): undefined reference to `cvCreateTrackbar'
CMakeFiles/vision1.dir/src/vision.cpp.o:vision.cpp:(.text+0x209): more undefined references to `cvCreateTrackbar' follow
CMakeFiles/vision1.dir/src/vision.cpp.o: In function `main':
vision.cpp:(.text+0x232): undefined reference to `cv::VideoCapture::read(cv::Mat&)'
vision.cpp:(.text+0x294): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
vision.cpp:(.text+0x2ac): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
vision.cpp:(.text+0x2d4): undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
vision.cpp:(.text+0x2fa): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
vision.cpp:(.text+0x3e0): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
vision.cpp:(.text+0x40c): undefined reference to `cv::inRange(cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&)'
vision.cpp:(.text+0x49e): undefined reference to `cv::getStructuringElement(int, cv::Size_<int>, cv::Point_<int>)'
vision.cpp:(.text+0x4b9): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
vision.cpp:(.text+0x4d1): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
vision.cpp:(.text+0x4e9): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
vision.cpp:(.text+0x52c): undefined reference to `cv::erode(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::Point_<int>, int, int, cv::Scalar_<double> const&)'
vision.cpp:(.text+0x5c0): undefined reference to `cv::getStructuringElement(int, cv::Size_<int>, cv::Point_<int>)'
vision.cpp:(.text+0x5db): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
vision.cpp:(.text+0x5f3): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
vision.cpp:(.text+0x60b): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
vision.cpp:(.text+0x64e): undefined reference to `cv::dilate(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::Point_<int>, int, int, cv::Scalar_<double> const&)'
vision.cpp:(.text+0x6e2): undefined reference to `cv::getStructuringElement(int, cv::Size_<int>, cv::Point_<int>)'
vision.cpp:(.text+0x6fd): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
vision.cpp:(.text+0x715): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
vision.cpp:(.text+0x72d): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
vision.cpp:(.text+0x770): undefined reference to `cv::dilate(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::Point_<int>, int, int, cv::Scalar_<double> const&)'
vision.cpp:(.text+0x804): undefined reference to `cv::getStructuringElement(int, cv::Size_<int>, cv::Point_<int>)'
vision.cpp:(.text+0x81f): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
vision.cpp:(.text+0x837): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
vision.cpp:(.text+0x84f): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
vision.cpp:(.text+0x892): undefined reference to `cv::erode(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::Point_<int>, int, int, cv::Scalar_<double> const&)'
vision.cpp:(.text+0x8b8): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
vision.cpp:(.text+0x8f2): undefined reference to `cv::imshow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
vision.cpp:(.text+0x920): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
vision.cpp:(.text+0x95a): undefined reference to `cv::imshow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
vision.cpp:(.text+0x97c): undefined reference to `cv::waitKey(int)'
vision.cpp:(.text+0xa1e): undefined reference to `cv::VideoCapture::~VideoCapture()'
vision.cpp:(.text+0xb15): undefined reference to `cv::VideoCapture::~VideoCapture()'
CMakeFiles/vision1.dir/src/vision.cpp.o: In function `cv::Mat::~Mat()':
vision.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x2b): undefined reference to `cv::fastFree(void*)'
CMakeFiles/vision1.dir/src/vision.cpp.o: In function `cv::Mat::release()':
vision.cpp:(.text._ZN2cv3Mat7releaseEv[cv::Mat::release()]+0x3b): undefined reference to `cv::Mat::deallocate()'
CMakeFiles/vision1.dir/src/vision.cpp.o: In function `cv::_InputArray::_InputArray(cv::Scalar_<double> const&)':
vision.cpp:(.text._ZN2cv11_InputArrayC2ERKNS_7Scalar_IdEE[_ZN2cv11_InputArrayC5ERKNS_7Scalar_IdEE]+0xb): undefined reference to `vtable for cv::_InputArray'
collect2: ld returned 1 exit status
make[2]: *** [/home/chiongsterx/catkin_ws/devel/lib/vision/vision1] Error 1
make[1]: *** [vision/CMakeFiles/vision1.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed

This is my Cmakelist. I am new to Ubuntu so i appreciate any help i can get. Thank you!

cmakeminimumrequired(VERSION 2.8.3) project(vision)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  tf

)

## Generate messages in the 'msg' folder
# add_message_files(
#   FILES
#   Message1.msg
#   Message2.msg
# )

## Generate services in the 'srv' folder
# add_service_files(
#   FILES
#   Service1.srv
#   Service2.srv
#)

## Generate actions in the 'action' folder
# add_action_files(
#   FILES
#   Action1.action
#   Action2.action
# )
## Generate added messages and services with any dependencies listed here
# generate_messages(
#   DEPENDENCIES
#   std_msgs  # Or other packages containing msgs
# )



###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
  ${catkin_INCLUDE_DIRS}
)

## Declare a cpp library
 #add_library(vision
 # src/${PROJECT_NAME}/vision.cpp
#)

## Declare a cpp executable
 add_executable(vision1 src/vision.cpp)


# add_dependencies(vision_node vision_generate_messages_cpp)

## Specify libraries to link a library or executable target against
 target_link_libraries(vision1
   ${catkin_LIBRARIES}
 )

Asked by chiongsterx on 2014-07-27 04:09:08 UTC

Comments

Answers

You need to link against opencv.

If you edit your question to include your CMakeLists.txt, I can give you a more precise answer.

Asked by ahendrix on 2014-07-27 16:46:22 UTC

Comments