Bohl's Blog

my digital life

building FFmpeg on Windows (6 of n)

Now that the configure/make-build of FFmpeg is working satisfactorily, it is time to turn to VisualStudio. We will create a VisualStudio-project from the results of the configure/make-build.

The approach I took is somewhat like: we run a configure/make-build which will create the config.h & config.asm files, a makefile and the dependencies. Then we use that information in order to create a VisualStudio-project-file (vcxproj) with the help of a little tool.

After configure has run, we run make with an option telling it to just print the commands it would normally execute:

make --dry-run > makelog.txt

The file "makelog.txt" now contains all compiler invocations, which we just need to parse and turn into a VisualStudio-project. Here is a little tool I put together for this job. I'll need to give it some more polish before releasing the source, so for now just the binary:

MakeVSProject.zip (23.59 kb)

Run this program with the following commandline:

MakeVSProject.exe --projname=vsFFmpeg -m makelog.txt

This will create two new files vsFFmpeg.vcxproj and vsFFmpeg.vcxproj.filters. Open the project with VisualStudio and it should look like this: 

Now, we are almost there, just some more tweaks are required. First of all, the VisualStudio-project includes both x86- and x64-platform, but configure has created config.h & config.asm tailored for just one platform. So we need to add some #ifdef's to these files - that's what the commands below will do:

sed 's/%define ARCH_X86_32 [0-1]//' < config.asm | sed 's/%define ARCH_X86_64 [0-1]//' > config.asm_out
sed 's/%define HAVE_ALIGNED_STACK [0-1]/%if ARCH_X86_32 == 1\n %define HAVE_ALIGNED_STACK 0\n%elif ARCH_X86_64 == 1\n %define HAVE_ALIGNED_STACK 1\n%endif/' < config.asm_out > config.asm
rm config.asm_out

sed 's/#define ARCH_X86_32 [0-1]/#if defined( _M_X64)\n #define ARCH_X86_32 0\n#elif defined( _M_IX86)\n #define ARCH_X86_32 1\n#endif\n/' < config.h | sed 's/#define ARCH_X86_64 [0-1]/#if defined( _M_X64)\n #define ARCH_X86_64 1\n#elif defined( _M_IX86)\n #define ARCH_X86_64 0\n#endif\n/' > config.h_out
sed 's/#define HAVE_ALIGNED_STACK [0-1]/#if defined( _M_X64)\n #define HAVE_ALIGNED_STACK 1\n#elif defined( _M_IX86)\n #define HAVE_ALIGNED_STACK 0\n#endif\n/' < config.h_out > config.h
rm config.h_out

Now the x86- and x64-Release builds should work right out of the box. There are still problems with the x64-Debug and x86-Debug build. With the former one you will get

 

and with the latter something like

 

I will have some more patches for this in the next post.

Of course, the VisualStudio-project still leaves some things to be desired. Foremost, it only includes the files which are producing an object file, headers and files that are only included are missing. I'd think it should be easy to parse the dependency-files (".d") in order to get them. Watch out for an update - again in a later post.

Kommentar schreiben

Loading