-   Programming (
-   -   Error while using OpenCv (

mangatrai 06-23-2012 04:26 PM

Error while using OpenCv
I just installed opencv on fedora 17. I downloaded the following sample program from the official site to confirm my installation.

sample program -

Later when I compiled, I get the following errors along with others of similar types.

try.cpp:(.text+0xea8): undefined reference to `cv::fillPoly(cv::Mat&, cv::Point_<int> const**, int const*, int, cv::Scalar_<double> const&, int, int, cv::Point_<int>)'
try.cpp:(.text+0xec0): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
try.cpp:(.text+0xf08): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
try.cpp:(.text+0xf30): undefined reference to `cv::waitKey(int)'

All these functions have been there in the included header files. #include path given is relative to /usr/include, so it seems to be right. plus all these have there libraries too at /usr/lib/, /usr/lib/ etc. which is again the default path where the linker will search for library. I really couldn't figure out that why g++ couldn't find the definations for these functions.

Thank you in advance!

Mangat Rai Modi

knudfl 06-24-2012 08:03 AM

Welcome to LQ.

drawing.cpp , line 1, 2 :
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"

Please try editing to :
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>


mangatmodi 06-25-2012 09:48 AM


Thanks for the help, however both the syntex are correct and in use. I solved the problem, it was linking error indeed. I used following command to compile my program and it worked fine

try.cpp -Wall /lib/ /lib/
btw, how report this thread as solved?

Mangat Rai Modi

knudfl 06-26-2012 04:19 PM

Marking a thread as solved :

Please use the "Thread Tools" right above post #1 :
... And select : Mark as 'Solved'.

All times are GMT -5. The time now is 05:48 PM.