LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Error while using OpenCv (https://www.linuxquestions.org/questions/programming-9/error-while-using-opencv-4175413033/)

mangatrai 06-23-2012 04:26 PM

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

sample program - http://code.opencv.org/svn/opencv/tr...pp/drawing.cpp

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

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/libopencv_core.so, /usr/lib/libopencv_highgui.so 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

@knudfl

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
Code:

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

--
Regards,
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 01:42 AM.