0

I have wrote a simple program like this

#include <opencv2/opencv.hpp>

using namespace cv;

int main(int argc, const char* argv[])
{
    Mat input = imread(argv[1], 0); //Load as grayscale
    //~ FAST detector;
    //~ vector<KeyPoint> keypoints;
    //~ FAST(input, keypoints, 0.2);

    // Add results to image and save.
    //~ Mat output;
    //~ drawKeypoints(input, keypoints, output);
    namedWindow ("Image", CV_WINDOW_FREERATIO);
    imshow("Image", input);
    //~ imwrite(argv[2], output);

    return 0;
}

Then compile program like this:

g++ `pkg-config --libs opencv` main.cpp

And here is output of g++:

/tmp/ccK1Sbrw.o: In function `main':
main.cpp:(.text+0x66): undefined reference to `cv::imread(std::string const&, int)'
main.cpp:(.text+0xc2): undefined reference to `cv::namedWindow(std::string const&, int)'
main.cpp:(.text+0xf6): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
main.cpp:(.text+0x139): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
/tmp/ccK1Sbrw.o: In function `cv::Mat::~Mat()':
main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'
/tmp/ccK1Sbrw.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

I have the library installed, I can see *.so and *.hpp files in their folders, and ld find them, but what does it complain about? there is nothing in .so files?!

Also, I do not have nonfree modules installed (I uset apt-get to install opencv), how can I get them? I need SIFT which is inside that module. Do I have to compile opencv myself?

1 Answer 1

1

It appears to me that you forgot to specify a module in

`pkg-config --libs MODULENAMEGOESHERE`
Sign up to request clarification or add additional context in comments.

2 Comments

sorry, it was a typo. but the answer was here stackoverflow.com/questions/7816607/…
what about nonfree? I see some opencv examples use that, but how to get that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.