0
我已經寫了一個簡單的程序,這樣不能編譯在Ubuntu的OpenCV程序
#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;
}
然後編譯這樣的程序:
g++ `pkg-config --libs opencv` main.cpp
這裏是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
我已經安裝了圖書館,我可以看到*的.so和*在他們的文件夾.HPP文件,ld
找到他們,但它抱怨什麼? .so文件中沒有任何內容?!
另外,我沒有安裝非自由的模塊(我USET apt-get
安裝OpenCV的),我怎樣才能得到呢?我需要該模塊內部的SIFT。我必須自己編譯opencv嗎?
抱歉地指定一個模塊,它是一個錯字。 但得到的答覆是這裏http://stackoverflow.com/questions/7816607/opencv-2-3-compiling-issue-undefined-refence-ubuntu-11-10 – vfsoraki
什麼非自由?我看到一些opencv的例子使用它,但是如何得到它呢? – vfsoraki