Ask Your Question
0

Undefined reference to algorithm

asked 2013-01-07 20:08:51 -0600

Szczepan gravatar image

updated 2013-01-08 07:40:42 -0600

I want to write a program for a raspberry pi witch can recognize road signs. I found that tutorial http://docs.opencv.org/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.html but when I try to run that I got following error "undefined reference to cv::Algorithm::~Algorithm". I'm including same library including features2d.hpp witch is now moved to the nonfree:

#include<opencv2/nonfree/features2d.hpp>
edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
1

answered 2013-01-08 10:21:50 -0600

Guanta gravatar image

updated 2013-01-09 04:44:49 -0600

First, I'd include

#include <opencv2/nonfree/nonfree.hpp>

Second you need to initialize the non-free module:

cv::initModule_nonfree();

edit Maybe the following CMakeLists.txt helps you building it (afaik the pkg-config file is still broken in the current opencv-version):

project(Test)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
find_package( OpenCV REQUIRED )
if( OpenCV_FOUND )
list( APPEND ThirdParty_LIBS ${OpenCV_LIBS} )
    include_directories( ${OpenCV_INCLUDE_DIRS} )
endif( OpenCV_FOUND )

set(${PROJECT_NAME}_SRC test.cpp)
add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_SRC})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
edit flag offensive delete link more

Comments

I got next error. I checked but there is no syntax error. initModule_nonfree was not declared in the scope. Edit: Now I added nonfree.hpp and i got error "undefined reference to 'cv::initModule_nonfree()"

Szczepan gravatar imageSzczepan ( 2013-01-08 15:32:25 -0600 )edit

Then, in your building process is something wrong! I just checked the example and modified it according to my post above and it built without an error. Maybe my CMakeLists.txt file which I used to build the test.cpp helps you to build it, just use ccmake for configuring it and then make to build it.

Guanta gravatar imageGuanta ( 2013-01-09 04:42:12 -0600 )edit

This is an old post, I know, but the Cmake trick did it for me, after I had installed nonfree from a repository on Ubuntu 14.04. Thanks!

alrekr gravatar imagealrekr ( 2015-12-15 13:35:55 -0600 )edit
0

answered 2016-08-11 09:37:52 -0600

Arritmic gravatar image

Many times the problem is related to the order of the libraries:

LIBS += -lopencv_imgcodecs -lopencv_objdetect -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_video
LIBS += -L$${_OPENCV_PATH_ANDROID}/sdk/native/3rdparty/libs/armeabi-v7a -ltbb

I need to put "-lopencv_objdetect" before "-lopencv_core"

edit flag offensive delete link more
0

answered 2013-01-08 07:42:40 -0600

cv::Algorithm class is implemented in core module. You need to add opencv_core to linker library list, i.e. -lopencv_core.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-01-07 20:08:51 -0600

Seen: 4,735 times

Last updated: Aug 11 '16