4

I'm trying to use ffmpeg in my C++ project on VS2010, and the ffmpeg dev version provides the lib of .h files. I linked these .libs in my projects and the corresponding .dlls are required when running the .exe file. But I want to link the ffmpeg lib statically and running without .dlls.

I tryed to compile the ffmpeg source code on windows with Mingw, only resulting on some .a archive files. How to get ffmpeg static .lib files? And it's a 64bit program so 64bit static lib is required.

程栋彬
  • 43
  • 1
  • 5

1 Answers1

2

In your output directory, you have some *.def files. You can use these files to get your *.lib files. The syntax is:

lib /def:avcodec-54.def /out:avcodec-54.lib

Use the lib.exe of your VS version. Mine is located in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin. Check the command line options (it way be useful to add /machine:i386).

Another way to do this: instead of using windows's cmd directly to start msys/mingw, first start VS command prompt (you can start it from Start menu). It will set some environment variables. From here, compile FFmpeg with msys/mingw: FFmpeg build will autodetect that VS is present, thus will auto-perform the libcall.

Edit: Sorry, I skipped the "static" part of the question. Here are some tips for a static build (note that I've never build a static FFmpeg used inside visual studio, so maybe it will not work). First, of course, FFmpeg must be built with the static options: just to be sure, I use these options, so I have no .def of shared files:

./configure --enable-static --disable-shared [other options]

In order to have statically files, you may directly use the .a files (again: I never thried this). Check this question.

If it does not work, you can try the visual studio toochain instead of gcc. But be careful: last time I tried this (but a shared dll), FFmpeg decoding was slower when build from msvc than gcc's output. Check this page for detailed build instructions.

Community
  • 1
  • 1
biskitt
  • 1,381
  • 1
  • 10
  • 13
  • Thanks for your answer. Actually, I had compiled ffmpeg in the second way you said, only get *.def files and *.a type of static lib. I tried the lib.exe to transfer *.def to *.lib as the first way you said, and *.lib files are generated. But they seem not to be static lib file according the file size. They have the corresponding same size with those *.lib files which are used with *.dll files. – 程栋彬 Sep 24 '14 at 02:01
  • I totally missed the "static" point, sorry. I updated my answer with some links, but I never did this myself. – biskitt Sep 24 '14 at 07:26
  • Thanks a lot for your help again, I almost know how to compile ffmpeg in windows, I will try these two ways of getting static *.lib files. – 程栋彬 Sep 25 '14 at 15:21