我试图编译 OpenCV 的 VideoCapture 示例。当我编译它时,我得到以下输出:
gpp test.c
Info: resolving vtable for cv::VideoCapture by linking to __imp___ZTVN2cv12VideoCaptureE (auto-import)
c:/programs/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/ld.exe: warning: auto-importing has
enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.
(顺便说一句,gpp 是 g++ -lhighgui -lcv -lcxcore 的别名)
因此,我尝试使用“gpp --enable-auto-import”进行编译,但 g++ 无法识别此选项。所以,我试着像这样编译:
gpp -c test.c
ld test.o
而且我遇到了同样的错误以及关于 STL 函数的许多其他错误,表明它没有与 STL 链接:
undefined reference to std::cout
...
最后,当我这样编译时:
gpp -c test.c
ld --enable-auto-import test.o
这一次,我只有 STL 错误。VideoCapture 错误消失了!所以我想我解决了这个问题。唯一的事情是:如何使 ld 将我的程序与 STL 库链接??????
提前致谢