Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

undefined refference to imread

I have openCV installed on server, and basic program

#include <iostream>

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

using namespace cv;
using namespace std;


int main()
{
    Mat RGBImage;

    RGBImage =imread("uno.png");
   cout << RGBImage.size();
    return 0;
}

and compillin it with

g++ main.cpp -I/opt/robots/pepper/ctc-linux64-atom-2.5.10.7/opencv2/include/

but i recieve error:

/tmp/ccqypB17.o: In function main': main.cpp:(.text+0x6d): undefined reference to cv::imread(std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> > const&, int)' /tmp/ccqypB17.o: In function cv::Mat::~Mat()': main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to cv::fastFree(void*)' /tmp/ccqypB17.o: In function cv::Mat::operator=(cv::Mat const&)': main.cpp:(.text._ZN2cv3MataSERKS0_[_ZN2cv3MataSERKS0_]+0x117): undefined reference to cv::Mat::copySize(cv::Mat const&)' /tmp/ccqypB17.o: In function cv::Mat::release()': main.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x47): undefined reference to cv::Mat::deallocate()' collect2: error: ld returned 1 exit status

Why is this happening?

if o omite code and just compile it with

#include <iostream>

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

using namespace cv;
using namespace std;


int main()
{

    return 0;
}

it works fine.

i tried usin

g++ main.cpp -I/opt/robots/pepper/ctc-linux64-atom-2.5.10.7/opencv2/include/ -L/opt/robots/pepper/ctc-linux64-atom-2.5.10.7/opencv2/lib

but error is same..

Why is this happening? Am i compilinng with wrong commands? I am tryin to make it work for over 2 weeks and still unsucessfully.. please help :(

click to hide/show revision 2
None

updated 2019-11-13 01:36:22 -0600

berak gravatar image

undefined refference to imread

I have openCV installed on server, and basic program

#include <iostream>

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

using namespace cv;
using namespace std;


int main()
{
    Mat RGBImage;

    RGBImage =imread("uno.png");
   cout << RGBImage.size();
    return 0;
}

and compillin it with

g++ main.cpp -I/opt/robots/pepper/ctc-linux64-atom-2.5.10.7/opencv2/include/

but i recieve error:

/tmp/ccqypB17.o: In function main': main.cpp:(.text+0x6d): undefined reference to cv::imread(std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> > const&, int)' /tmp/ccqypB17.o: In function cv::Mat::~Mat()': main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to cv::fastFree(void*)' /tmp/ccqypB17.o: In function cv::Mat::operator=(cv::Mat const&)': main.cpp:(.text._ZN2cv3MataSERKS0_[_ZN2cv3MataSERKS0_]+0x117): undefined reference to cv::Mat::copySize(cv::Mat const&)' /tmp/ccqypB17.o: In function cv::Mat::release()': main.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x47): undefined reference to cv::Mat::deallocate()' collect2: error: ld returned 1 exit status

Why is this happening?

if o omite code and just compile it with

#include <iostream>

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

using namespace cv;
using namespace std;


int main()
{

    return 0;
}

it works fine.

i tried usin

g++ main.cpp -I/opt/robots/pepper/ctc-linux64-atom-2.5.10.7/opencv2/include/ -L/opt/robots/pepper/ctc-linux64-atom-2.5.10.7/opencv2/lib

but error is same..

Why is this happening? Am i compilinng with wrong commands? I am tryin to make it work for over 2 weeks and still unsucessfully.. please help :(