【发布时间】:2011-04-09 05:51:57
【问题描述】:
我试图编译 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 库链接??????
提前致谢
【问题讨论】:
-
解决了。虽然 ld 上的参数是“--enable-auto-import”,但在使用 g++ 编译时,您只能使用“-enable-auto-import”。这样,我就能够编译并运行我的示例。