0

I downloaded the most recent Zeranoe dev build here, included the header files to my code, placed extern "C" around the includes, since this is a C++ project and FFmpeg is a C library, and added the libs to Visual Studio as well, and I get this linker error:

1>Camera.obj : error LNK2019: unresolved external symbol _av_free referenced in function __catch$?NewFrameReceived@Camera@MicroDFV_Camera@@AAEXKKKGPAE@Z$0 1>Camera.obj : error LNK2019: unresolved external symbol _av_freep referenced in function __catch$?NewFrameReceived@Camera@MicroDFV_Camera@@AAEXKKKGPAE@Z$0 1>Camera.obj : error LNK2019: unresolved external symbol _av_frame_alloc referenced in function __catch$?NewFrameReceived@Camera@MicroDFV_Camera@@AAEXKKKGPAE@Z$0 1>Camera.obj : error LNK2019: unresolved external symbol _av_frame_free referenced in function __catch$?NewFrameReceived@Camera@MicroDFV_Camera@@AAEXKKKGPAE@Z$0 1>Camera.obj : error LNK2019: unresolved external symbol _avcodec_register_all referenced in function __catch$??0Camera@MicroDFV_Camera@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0PAX@Z$0 1>Camera.obj : error LNK2019: unresolved external symbol _avcodec_alloc_context3 referenced in function __catch$?NewFrameReceived@Camera@MicroDFV_Camera@@AAEXKKKGPAE@Z$0 1>Camera.obj : error LNK2019: unresolved external symbol _avcodec_open2 referenced in function __catch$?NewFrameReceived@Camera@MicroDFV_Camera@@AAEXKKKGPAE@Z$0 1>Camera.obj : error LNK2019: unresolved external symbol _avcodec_close referenced in function __catch$?NewFrameReceived@Camera@MicroDFV_Camera@@AAEXKKKGPAE@Z$0 1>Camera.obj : error LNK2019: unresolved external symbol _av_init_packet referenced in function __catch$?NewFrameReceived@Camera@MicroDFV_Camera@@AAEXKKKGPAE@Z$0 1>Camera.obj : error LNK2019: unresolved external symbol _av_packet_unref referenced in function __catch$?NewFrameReceived@Camera@MicroDFV_Camera@@AAEXKKKGPAE@Z$0 1>Camera.obj : error LNK2019: unresolved external symbol _avcodec_find_encoder referenced in function __catch$?NewFrameReceived@Camera@MicroDFV_Camera@@AAEXKKKGPAE@Z$0 1>Camera.obj : error LNK2019: unresolved external symbol _avcodec_encode_video2 referenced in function __catch$?NewFrameReceived@Camera@MicroDFV_Camera@@AAEXKKKGPAE@Z$0 1>Camera.obj : error LNK2019: unresolved external symbol _av_opt_set referenced in function __catch$?NewFrameReceived@Camera@MicroDFV_Camera@@AAEXKKKGPAE@Z$0 1>Camera.obj : error LNK2019: unresolved external symbol _av_image_alloc referenced in function __catch$?NewFrameReceived@Camera@MicroDFV_Camera@@AAEXKKKGPAE@Z$0 1>M:\Desktop\OpenCVTest\Debug\OpenCVTest.exe : fatal error LNK1120: 14 unresolved externals

Searching here and on Google I found many recommendations, such as to add #pragma comment(lib,...), and that the libs are static, so their order is important, and none of this helps.

So I scratched my head even more and realized that the Zeranoe build is made with MinGW-w64, so probably it won't link with Visual Studio. I inspected the lib using dumpbin and the symbols on the libs don't have the underscore, so I am pretty sure it won't work.

The other Zeranoe builds for Windows don't have libs, they are just plain .exe or exe + .dll.

Will I have to make my own VS2013 build of FFmpeg to link it, or is there some alternative way?

Michel Feinstein
  • 13,416
  • 16
  • 91
  • 173
  • Looks like some name-mangling problem. That is a C++ issue, not a C one. Please remove the C tag. – too honest for this site Jan 19 '16 at 01:30
  • Ffmpeg is written on C, I use extern "C" to avoid c++ name mangling, as as I said in my post. This more like the calling conventions of visual studio not being the same as mingw-w64.... Visual Studio has some configurations for this that change the name of the functions and also the calling conventions... Like using __cdelc – Michel Feinstein Jan 19 '16 at 01:44
  • I think this is more a C problem than a C++, because all points to a C compilation not being compatible with Visual Studio's conventions..... And it's easy to see in the error that the symbols are C indeed... If they were a C++ naming mangling, they will be as complicated as the functions names calling them, in the same error message (and they are not, because of the extern "C) – Michel Feinstein Jan 19 '16 at 01:48
  • C is standardised. If you use a non-compliant compiler or try to compile C code with a C++ compiler you are lost anyway. But the messages above are from the linker, not the compiler. SO either you do not link necessary object file(s) or your compiler generates strange names. Either way, it is not a matter of the C language. Oh, and the leading underscores are actually some VisualStudio thing. Another legacy from old times when a C compiler added underscores to the symbols it generated. Just use a proper toolchain or try compiling all in VS/MSVC(++). Good luck! (No pun intended) – too honest for this site Jan 19 '16 at 01:56
  • So you are suggesting that Visual Studio isn't complying with the C standard for calling conventions? As far as I know, calling conventions are not standard and different systems and compilers adopt different standards. – Michel Feinstein Jan 19 '16 at 02:21
  • The C standard does not define any calling conventions. How could it, as these are part of the ABI/PCS which heavily depends on the target architecture&platform. But that still does not necessarily cover naming conventions for symbols with external linkage. IIRC (long time ago I had to use Windows), the underscore is a difference. But maybe you just used the wrong options, your MinGW is malconfigured, or whatever. What I stated is just that this is a relic from early times - much as still not supporting a >16 year old commonly accepted and truely enhanced standard, but stick to a >25 year old. – too honest for this site Jan 19 '16 at 12:11
  • what this is showing is the link step is missing a library. Please post the makefile contents – user3629249 Jan 19 '16 at 13:10
  • I am not making the libraries, I downloaded them from Zeranoe's website, they are in FFmpeg website, under "Windows builds". My point is to avoid making my own build, I want to use the avaliable build, since it's time consuming and complicated to make my own build. – Michel Feinstein Jan 19 '16 at 13:17

0 Answers0