[FFmpeg-devel] Building FFmpeg with icc-win32 [Re: C99 or GCC extensions]

Peter Ross pross
Tue Nov 18 12:24:19 CET 2008


Hi,

Below are some loose instructions on how to compile FFmpeg for Microsoft
Windows *using* the Intel icc-win32 compiler. Several folks have sent 
private RFIs about this, but its better to make the info more public.

In summary, YES, icc-win32 can compile a working ffpeg.exe for Windows,
assembly optimisations must be disabled, because icc-win32 does not
presently support AT&T-style assembly syntax.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)

----- Forwarded message from pross -----

To: Axel Holzinger <aholzinger at gmx.de>
Subject: Re: [FFmpeg-devel] C99 or GCC extensions

On Sat, Jul 05, 2008 at 11:34:43AM +0200, Axel Holzinger wrote:
> Hi Peter,
> 
> I write to you by direct email to not soil the group. I hope this is
> okay for you.
> 
> Peter <pross at xvid.org> wrote:
> 
> > ...
> > 
> > Coincidently I hit the same problem recently when compiling ffmpeg
> > with icc-win32. Patch enclosed.
> 
> This is very interesting, I stumbled over that working on exactly the
> same task :-)
> 
> I found out that icc doesn't offer Gnu89 extensions in the win32
> version.
> 
> How do you use icc, from within MSys and standard FFmpeg configure
> resp. make or do you use it within Visual Studio?

Using Cygwin+Makefile. I did not using icc-win32 in any 'serious' manner,
just to debug a problem in windows.  It's a royale PITA to get working, so
here's a quick rundown of what I did.


1. Modify cygwin. Insert following line at the start of c:/cygwin/cygwin.bat.
   @CALL "C:\Program Files\Intel\Compiler\C++\10.1.013\IA32\Bin\ICLVars.bat"

2. FFmpeg assumes gcc flag syntax is supported. icc-win32 uses Microsoft flag synax.
   Patch configure and common.mak (i.e. -c becomes /c, -o becomes /Fo, etc.)
   (Patch enclosed).

3. Fix your Microsoft C standard library: C:\Program Files\Microsoft Visual Studio 9.0\VC\include
   stdint.h, inttypes: http://msinttypes.googlecode.com/
   strings.h, unitstd.h, sys/time.h
   (Files enclosed. These are sufficient to get ffmpeg.exe working, but are very crude)

4. FFmpeg's configure script will default to using cygwin's "/tmp", but ICL doesnt know about cygwin's
   VFS, so force it to something else:

   export TMPDIR="C:\\temp"

   Then run configure:
   ./configure --cc=icl --extra-cflags="/MT /Oy /Qstd=c99 -D_USE_MATH_DEFINES=1 -D _CRT_SECURE_NO_WARNINGS=1 -Datoll=atol -Dsnprintf=_snprintf -Dstrcasecmp=_stricmp" --target-os=mingw32 --enable-memalign-hack --arch=unknown --disable-devices --disable-bsfs
   Nb: the extra -D's are hacks for the microsoft stdlib.
   Nb: --arch=unknown because my version of ICL does not support GNU-style inline assembly.
        (annoying, because the linux version provide a flag to choose assembly notation)

5. Modify config.mak
   Check OPTFLAGS, remove any spurious gcc-syntax (e.g. -W..., -fno...)
   Replace LDFLAGS=... with just LDFLAGS=
   Replace SHFLAGS=... with just SHFLAGS=
   Replace DEPEND_CMD=... with DEPEND_CMD=echo

6. llrint, lrint, either one is missing.

7. ICL does not like inline array definitions. 
   So, grep the source code for AVRational. Replace all inline array defintions, e.g.
       blah = (AVRation){1,25}
   with
       const AVRational blash_const = {1,25};
       blah = blah_const;

8. make

9. Linking of ffmpeg.exe intially failed. IIRC, I resorted to the Intel/Microsoft Linker.

Cheers,

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)

Index: configure
===================================================================
--- configure	(revision 13836)
+++ configure	(working copy)
@@ -421,14 +421,14 @@
     log check_cc "$@"
     cat > $TMPC
     log_file $TMPC
-    check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
+    check_cmd $cc $CFLAGS "$@" /c /Fo$TMPO $TMPC
 }
 
 check_cpp(){
     log check_cpp "$@"
     cat > $TMPC
     log_file $TMPC
-    check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
+    check_cmd $cc $CFLAGS "$@" /E /Fo$TMPO $TMPC
 }
 
 check_asm(){
@@ -449,7 +449,7 @@
     for f; do
         test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
     done
-    check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
+    check_cmd $cc $LDFLAGS $flags /Fe$TMPE $TMPO $extralibs $libs
 }
 
 check_cflags(){
@@ -1099,7 +1099,7 @@
 TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
 TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}"
 TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
-TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
+TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.obj"
 TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
 TMPSH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
 
@@ -1399,7 +1399,7 @@
     fi
 fi
 
-disabled optimizations || add_cflags -fomit-frame-pointer
+disabled optimizations || add_cflags /Oy
 
 # Add processor-specific flags
 if test $cpu != "generic"; then
Index: common.mak
===================================================================
--- common.mak	(revision 13836)
+++ common.mak	(working copy)
@@ -18,13 +18,13 @@
 ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
 
 CFLAGS := -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
-          -D_ISOC9X_SOURCE -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(OPTFLAGS)
+          -D_ISOC9X_SOURCE /I$(BUILD_ROOT_REL) /I$(SRC_PATH) $(OPTFLAGS)
 
 %.o: %.c
-	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
+	$(CC) $(CFLAGS) $(LIBOBJFLAGS) /c /Fo$@ $<
 
 %.o: %.S
-	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
+	$(CC) $(CFLAGS) $(LIBOBJFLAGS) /c /Fo$@ $<
 
 %.ho: %.h
 	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
@@ -63,7 +63,7 @@
 TESTS    += $(TESTS-yes)
 
 FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
-FFLDFLAGS   := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
+FFLDFLAGS   := $(addprefix -L $(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
 
 SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPP_OBJS:.o=.cpp)
 OBJS := $(OBJS) $(ASM_OBJS) $(CPP_OBJS)
@@ -86,13 +86,13 @@
 
 define RULES
 $(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
-	$(CC) $(FFLDFLAGS) -o $$@ $$^ $(SUBDIR)$(LIBNAME) $(FFEXTRALIBS)
+	$(CC) $(FFLDFLAGS) /Fe$$@ $$^ $(SUBDIR)$(LIBNAME) $(FFEXTRALIBS)
 
 $(SUBDIR)%-test.o: $(SUBDIR)%.c
-	$(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
+	$(CC) $(CFLAGS) -DTEST /c /Fo$$@ $$^
 
 $(SUBDIR)%-test.o: $(SUBDIR)%-test.c
-	$(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
+	$(CC) $(CFLAGS) -DTEST /c /Fo$$@ $$^
 
 clean::
 	rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \





----- End forwarded message -----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081118/a00a8a72/attachment.pgp>



More information about the ffmpeg-devel mailing list