LD: link to STL libraries

I tried to compile an OpenCV VideoCapture example. When I compile it, I get the following output:

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.

(Btw, gpp is an alias of g ++ -lhighgui -lcv -lcxcore)

So, I tried to compile with "gpp -enable-auto-import", but g ++ did not recognize this option. So, I tried to compile like this:

gpp -c test.c
ld test.o

And I have the same error And many other errors about STL functions, indicating that they did not communicate with STL:

undefined reference to std::cout
...

And finally, when I compiled as follows:

gpp -c test.c
ld --enable-auto-import test.o

This time I got STL errors. Error VideoCapture has disappeared! So I decided that I solved this problem. The only thing: how to make ld a link to my program with STL libraries ??????

Thanks in advance

+3
source share
1

g++ test.c -lhighgui -lcv -lcxcore -Wl,--enable-auto-import

"gpp", , ( ), --enable-auto-import .

"" "".

+2

Source: https://habr.com/ru/post/1763623/


All Articles