English 中文(简体)
OpenCV 2.3 Compiling Issue - Un Defin Refence - 乌班图11.10
原标题:OpenCV 2.3 Compiling Issue - Undefined Refence - Ubuntu 11.10

System Info: Ubuntu 11.10 (64 bits) with OpenCV 2.3 (installed today)

我试图将一些非常简单的法典编成开放式CV2.3,但Im却留下了错误。

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

int main(){
  cv::Mat image=cv::imread("img.jpg");
  cv::namedWindow("My Image");
  cv::imshow("My Image",image);
  cv::waitKey(0);
  return 1;
}

然而,我拿到这些错误信息......

-SG41:~/Desktop$ g++ `pkg-config opencv --cflags --libs` -o test_1 test_1.cpp 
/tmp/ccCvS1ys.o: In function `main :
test_1.cpp:(.text+0x44): undefined reference to `cv::imread(std::basic_string<char,    std::char_traits<char>, std::allocator<char> > const&, int) 
test_1.cpp:(.text+0x8e): undefined reference to `cv::namedWindow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) 
test_1.cpp:(.text+0xbc): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&) 
test_1.cpp:(.text+0xf0): undefined reference to `cv::imshow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&) 
test_1.cpp:(.text+0x112): undefined reference to `cv::waitKey(int) 
/tmp/ccCvS1ys.o: In function `cv::Mat::~Mat() :
test_1.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*) 
/tmp/ccCvS1ys.o: In function `cv::Mat::release() :
test_1.cpp:(.text._ZN2cv3Mat7releaseEv[cv::Mat::release()]+0x47): undefined reference to `cv::Mat::deallocate() 
collect2: ld returned 1 exit status
问题回答

我猜测,在产出中,至少部分图书馆投入使用。

pkg-config opencv --libs

档案图书馆。 将档案图书馆放在需要其来源之前是不正确的(test_1.cpp in this case: the order of sources and Library on thelink Line matters

提 出

g++ -o test_1 test_1.cpp `pkg-config opencv --cflags --libs` 

我也存在同样的问题,但我发现,没有“-I/usr/include/opencv”,而是“-I/usr/include/opencv2”。 能否在乌班图举行一揽子计划?

@Employed Russian的回答也为我工作。 对那些想如何在Eclipse中具体说明这一指挥的人来说,使用这一职位——

https://www.eclipse.org/forums/index.php?t=msg&goto=233377&

Instead of adding gtk+, use opencv; Instead of adding the new flags to Miscellaneous linker flags , add the new flags at the end after ${INPUT} in - Project->Right click->Properties->C/C++ Build ->Settings->GCC C++ linker->Expert Settings: command line pattern





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签