OpenCV 2.4 static lib relies on opencv_ffmpeg*.dll on Windows

asked 2015-03-02 03:50:43 -0600

davidshen gravatar image

I want to compile a simple C program which I would like to statically link to opencv*.lib files. I am doing thin on Windows 64bit, with VS 2013.

I have included the include directory, the opencv\build\x64\vc12\staticlib directory, and all the necessary .lib files. The compilation went smoothly, but the program won't execute. More specifically,

VideoCapture::open(*filename*)

will fail, and

VideoCapture::isOpened()

will return false. But no exception of any kind is thrown.

I noticed if I put my executable under opencv\build\x64\vc12\bin, the program will work as expected. So I tried the combination of the DLLs and my program, and I found opencv_ffmpeg*.dll is the one causing my problem.

It seems to me that the static lib is dynamically linking to this ffmpeg DLL. So even my program can run without DLLs from opencv, I still need to satisfy the dependencies of the static lib, which is a dynamic lib...so complicate.

edit retag flag offensive close merge delete

Comments

You will need to statically build ffmpeg first yourself on your system before you can integrate it in OpenCV like you want. If not the dependency will indeed still exist. The reason of it being dynamically linked is due to the GPL licence ...

StevenPuttemans gravatar imageStevenPuttemans ( 2015-03-02 08:44:15 -0600 )edit
1

So, I need to:

  • Build static ffmpeg
  • Build static opencv and static link to ffmpeg
  • Build my program and static link to opencv & ffmpeg

That means I need to build everything from scratch...correct?

davidshen gravatar imagedavidshen ( 2015-03-02 21:09:30 -0600 )edit
1

Yep that is correct. But keep in mind that once you would deploy this code to a product, that the license prohibits you from using it commercially with a static ffmpeg, for free that is.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-03-03 02:19:13 -0600 )edit