1

I have installed opencv using the following commands: git clone https://github.com/jayrambhia/Install-OpenCV.git

cd Install-OpenCV/
./dependencies.sh
./opencv_latest.sh

this gave me the following message:

Package ffmpeg is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Deciding that this may or may not matter I went on into codeblock and created a default opencv template project.

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;

int main(int argc, char *argv[])
{
    Mat img = imread("lena.jpg", CV_LOAD_IMAGE_COLOR);
    if(img.empty())
       return -1;
    namedWindow( "lena", CV_WINDOW_AUTOSIZE );
    imshow("lena", img);
    waitKey(0);
    return 0;
}

This showed no errors but on compile gave me the following errors:

AR: 9 undfined reference to 'cv::imread(std::string const&,int)'
AR: 12 undfined reference to 'cv::na(std::string const&,int)'
AR: 13 undfined reference to 'cv::InputArray::_InputArray(cv::Mat const&)'
AR: 13 undfined reference to 'cv::imshow(std::string const&, cv::InputArray(const&)'
AR: 14 undfined reference to 'cv::waitKey(int)'
usr/include/opencv... 278 undfined reference to 'cv::fastFree(void*)'
usr/include/opencv... 367 undfined reference to 'cv::Mat::deallocate()'

running the getlatest under sudo instead gave me the following exchange:

sudo ./opencv_latest.sh
... some normal looking stuff...
./opencv_latest.sh: 7: ./opencv_install.sh: [[: not found
./opencv_latest.sh: 11: ./opencv_install.sh: [[: not found
./opencv_latest.sh: 15: ./opencv_install.sh: [[: not found
--- Installing OpenCV 2.4.9
--- Installing Dependencies
./opencv_latest.sh: 27: ./opencv_install.sh: source: not found

Attempting to do what they did here: http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation gave me the following result:

Prg1@KILLBOX:/usr/include/opencv2/release$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/include/opencv2
CMake Error: The source directory "/usr/include/opencv2/release/CMAKE_INSTALL_PREFIX=/usr/include/opencv2" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.

Here are picks of my linker and compiler settings: compiler linker

So anybody know what I'm doing wrong this is on ubuntu 14.04 LTS and codeblocks

edit: using ldconfig -p | grep opencv gave me a mountain of opencv files that should mean it's installed right, right? So it the problem with the linker and compiler? Note that linker settings in the compiler settings (not the search directories) show the opencv libs as being empty so which one is it? By the way clicking on the error messages in codeblocks (the once inside the opencv lib) does in fact bring up pieces of the opencv lib which look like the proper lines of code to be at that position (as in they contain functions that the log shows as missing)

Thijser
  • 2,625
  • 1
  • 36
  • 71
  • 1
    you miss to link opencv_core.a, opencv_highgui.a and maybe opencv_imgproc.a . you have to add them in some tab, and change the linker path above to the folder, where those libs are. (might be /usr/local/lib) – berak Jul 11 '14 at 10:10
  • Thank you that was the problem – Thijser Jul 11 '14 at 10:15
  • I would call it a sub question rather then a duplicate – Thijser Jul 11 '14 at 17:35

1 Answers1

1

Did you build your OpenCv properly after downloading it's source from git.
Check out this link :- http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html

Underfined reference error means that the linker is unable to find the code for the functions you are using in your project, as a result you need to first install opencv properly.

Pratik Singhal
  • 6,283
  • 10
  • 55
  • 97
  • According to my compiler output there is an error in the opencv library doesn't that mean that it's properly linked? And isn't that what the install latest is supposed to do? – Thijser Jul 11 '14 at 07:26
  • No, the compiler output you showed, tells that the linker is unable to find the object file for the code of openCV library. Whenever, you use some external library, you need to properly link your cpp file with the external libraries object code. – Pratik Singhal Jul 11 '14 at 07:27
  • Check out the following SO question http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix – Pratik Singhal Jul 11 '14 at 07:28
  • Attempting to build with /usr/include/opencv2/release$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/include/opencv2 gives me CMake Error: The source directory "/usr/include/opencv2/release/CMAKE_INSTALL_PREFIX=/usr/include/opencv2" does not exist. Specify --help for usage, or press the help button on the CMake GUI. Are you sure that's how I'm supposed to do this? – Thijser Jul 11 '14 at 07:35