View Full Version : Compiling x264 from a clean MinGW?
snow_xmas
2nd April 2007, 07:30
How to build x264 with MinGW?
snow_xmas
2nd April 2007, 15:06
My English isn't so good. And I'm not so good in programming. But I love x264 very much. x264 vfw was cancelled last year. Maybe the CLI can do anything that vfw can do. But I think vfw is necessary in some special case. So I want to build it myself so that I could use the latest version of this excellent vfw encoder. I have tried to build it with MinGW many time. As a result,all of that was fail. I have download the "nasm". But the errors don't disappear. Please tell me how to make x264 successful.
Terranigma
2nd April 2007, 20:52
My English isn't so good. And I'm not so good in programming. But I love x264 very much. x264 vfw was cancelled last year. Maybe the CLI can do anything that vfw can do. But I think vfw is necessary in some special case. So I want to build it myself so that I could use the latest version of this excellent vfw encoder. I have tried to build it with MinGW many time. As a result,all of that was fail. I have download the "nasm". But the errors don't disappear. Please tell me how to make x264 successful.
Have you checked celtic_druid (http://tirnanog.fate.jp/mirror/x264/)'s page? He does exactly what you're asking.
LoRd_MuldeR
2nd April 2007, 22:41
My English isn't so good. And I'm not so good in programming. But I love x264 very much. x264 vfw was cancelled last year. Maybe the CLI can do anything that vfw can do. But I think vfw is necessary in some special case. So I want to build it myself so that I could use the latest version of this excellent vfw encoder. I have tried to build it with MinGW many time. As a result,all of that was fail. I have download the "nasm". But the errors don't disappear. Please tell me how to make x264 successful.
If you need an almost up-to-date build of x264 VfW version, you can get it here:
http://kurtnoise.free.fr/index.php?dir=x264vfw/&file=x264vfw_r621.exe
In case you currently use VirtualDub + x264 VfW, I recommend you check out Avidemux instead:
http://www.avidemux.org/admForum/viewtopic.php?pid=17603#p17603
foxyshadis
3rd April 2007, 02:27
Split mingw compiling posts into new thread.
But can we get an answer on how it is done. I'm a linux user and I'm familiar with x264 compilation on linux. I know that instructions are somewhere there, but I have lately read to many docs and man man pages and I'm bit tired. I tried cd to c:\mingw\bin but there's no perl so I can't execute .configure like I do it on linux. Should I install perl runtimes? I just want to add march=k8 option because on linux that is 4-7% improvement in encoding speed, I tested it on my own.
ChronoCross
3rd April 2007, 05:20
if you show waht error message your getting in compile that should help.
also what is your ./configure command line.
snow_xmas
3rd April 2007, 11:56
I wonder that what compiler can build x264? Only MinGW or MinGW with MSYS?
I'm not so familier with MSYS. And I think it is so complex that don't like use it. Is MSYS necessary to build x264?
谢谢!!
snow_xmas
3rd April 2007, 11:58
I wonder that what compiler can build x264. Only MinGW or MinGW with MSYS?
I'm not so familier with MSYS. And I think it is so complex that don't like use it. Is MSYS necessary to build x264?
cc979
3rd April 2007, 12:09
you will need MSYS Developer Tool Kit (which includes perl) and msys from
http://www.mingw.org/download.shtml
and you will need to compile the gpac libs for the mp4 part in x264
http://gpac.sourceforge.net/
(not sure if you will need mp4 stuff for vfw part x264 tho)
think you need to compile zlib for gpac IIRC
http://www.zlib.net/
then after you have all the libs in place then compile x264
Msys is what I needed :). I was using cmd to do ./configure but msys comes with bash so now I know that it is the bash that I have to use not cmd.
snow_xmas
5th April 2007, 04:35
It shows that
"484886 [main] make 1156 proc_subproc: Couldn't duplicate my handle<0x7E4> for pid 0, Win32 error 6"
"497243 [main] make 1156 proc_subproc: Couldn't duplicate my handle<0x7E4> for pid 0, Win32 error 6"
"make: nasm: Command not found
make: *** [common/i386/cpu-a.o] Error 127"
I have download the "nasm" and extracted the "nasm.exe" "ndisasm.exe" into both "c:\mingw\bin\" and "C:\msys\1.0\bin". I really didn't know the mean that it shows.
gruntster
5th April 2007, 14:18
These steps work for me.
Install MinGW, MSYS and MSYS DTK
Extract nasmw.exe from the NASM zip file to the MinGW bin folder.
Rename nasmw.exe to nasm.exe.
Download Pthreads from http://sourceware.org/pthreads-win32
Run pthreads-w32-2-8-0-release.exe to extract required files to a temporary folder.
Copy the contents of the Pre-built.2\include folder to the MinGW include folder.
Copy all a and lib files from the Pre-built.2\lib folder to the MinGW lib folder.
Copy all dll files from the Pre-built.2\lib folder to the MinGW bin folder.
Start MSYS.
Change directory to the x264 source code, e.g. cd /c/dev/x264
Execute the following commands:
a. ./configure --prefix=/mingw --enable-pthread –-enable-avis-input –-enable-shared
b. make
c. make install
If you’d like to also produce a libx264.dll, execute the following command:
gcc -shared -Wl,-s -Wl,--out-implib,/mingw/lib/libx264.a -o /mingw/bin/libx264.dll ./common/*.o ./common/i386/*.o ./encoder/*.o -lpthreadGC2 -lvfw32
snow_xmas
6th April 2007, 05:00
Administrator@C217 ~
$ cd /f
Administrator@C217 /f
$ cd trunk
Administrator@C217 /f/trunk
$ ./configure --prefix=/mingw --enable-pthread --enable-avis-input --enable-shared
./version.sh: svnversion: command not found
Platform: X86
System: MINGW
avis input: yes
mp4 output: no
pthread: yes
gtk: no
debug: no
gprof: no
PIC: no
shared: yes
visualize: no
You can run 'make' or 'make fprofiled' now.
Administrator@C217 /f/trunk
$ make
rm -f .depend
( echo -n "`dirname common/mc.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/mc.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname common/predict.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/predict.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname common/pixel.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/pixel.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname common/macroblock.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/macroblock.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname common/frame.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/frame.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname common/dct.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/dct.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname common/cpu.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/cpu.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname common/cabac.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/cabac.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname common/common.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/common.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname common/mdate.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/mdate.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname common/csp.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/csp.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname common/set.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/set.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname common/quant.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/quant.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname encoder/analyse.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer encoder/analyse.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname encoder/me.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer encoder/me.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname encoder/ratecontrol.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer encoder/ratecontrol.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname encoder/set.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer encoder/set.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname encoder/macroblock.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer encoder/macroblock.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname encoder/cabac.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer encoder/cabac.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname encoder/cavlc.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer encoder/cavlc.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname encoder/encoder.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer encoder/encoder.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname encoder/eval.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer encoder/eval.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname common/i386/mc-c.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/i386/mc-c.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname common/i386/predict-c.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer common/i386/predict-c.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname x264.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer x264.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname matroska.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer matroska.c -MM -g0 ) 1>> .depend; ( echo -n "`dirname muxers.c`/" && gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer muxers.c -MM -g0 ) 1>> .depend;
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/mc.o common/mc.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/predict.o common/predict.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/pixel.o common/pixel.c
common/pixel.c: In function `x264_pixel_ssim_wxh':
common/pixel.c:388: warning: implicit declaration of function `alloca'
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/macroblock.o common/macroblock.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/frame.o common/frame.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/dct.o common/dct.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/cpu.o common/cpu.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/cabac.o common/cabac.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/common.o common/common.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/mdate.o common/mdate.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/csp.o common/csp.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/set.o common/set.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/quant.o common/quant.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o encoder/analyse.o encoder/analyse.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o encoder/me.o encoder/me.c
encoder/me.c: In function `x264_me_search_ref':
encoder/me.c:463: warning: implicit declaration of function `alloca'
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o encoder/ratecontrol.o encoder/ratecontrol.c
encoder/ratecontrol.c: In function `x264_ratecontrol_delete':
encoder/ratecontrol.c:567: warning: implicit declaration of function `unlink'
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o encoder/set.o encoder/set.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o encoder/macroblock.o encoder/macroblock.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o encoder/cabac.o encoder/cabac.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o encoder/cavlc.o encoder/cavlc.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o encoder/encoder.o encoder/encoder.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o encoder/eval.o encoder/eval.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/i386/mc-c.o common/i386/mc-c.c
gcc -O4 -ffast-math -Wall -I. -DHAVE_MMX -DARCH_X86 -DSYS_MINGW -DHAVE_PTHREAD -s -fomit-frame-pointer -c -o common/i386/predict-c.o common/i386/predict-c.c
nasm -O2 -f win32 -DPREFIX -Icommon/i386/ -o common/i386/dct-a.o common/i386/dct-a.asm
nasm -O2 -f win32 -DPREFIX -Icommon/i386/ -o common/i386/cpu-a.o common/i386/cpu-a.asm
nasm -O2 -f win32 -DPREFIX -Icommon/i386/ -o common/i386/pixel-a.o common/i386/pixel-a.asm
nasm -O2 -f win32 -DPREFIX -Icommon/i386/ -o common/i386/mc-a.o common/i386/mc-a.asm
nasm -O2 -f win32 -DPREFIX -Icommon/i386/ -o common/i386/mc-a2.o common/i386/mc-a2.asm
nasm -O2 -f win32 -DPREFIX -Icommon/i386/ -o common/i386/predict-a.o common/i386/predict-a.asm
nasm -O2 -f win32 -DPREFIX -Icommon/i386/ -o common/i386/pixel-sse2.o common/i386/pixel-sse2.asm
nasm -O2 -f win32 -DPREFIX -Icommon/i386/ -o common/i386/quant-a.o common/i386/quant-a.asm
nasm -O2 -f win32 -DPREFIX -Icommon/i386/ -o common/i386/deblock-a.o common/i386/deblock-a.asm
gcc -shared -o libx264.so.54 common/mc.o common/predict.o common/pixel.o common/macroblock.o common/frame.o common/dct.o common/cpu.o common/cabac.o common/common.o common/mdate.o common/csp.o common/set.o common/quant.o encoder/analyse.o encoder/me.o encoder/ratecontrol.o encoder/set.o encoder/macroblock.o encoder/cabac.o encoder/cavlc.o encoder/encoder.o encoder/eval.o common/i386/mc-c.o common/i386/predict-c.o common/i386/dct-a.o common/i386/cpu-a.o common/i386/pixel-a.o common/i386/mc-a.o common/i386/mc-a2.o common/i386/predict-a.o common/i386/pixel-sse2.o common/i386/quant-a.o common/i386/deblock-a.o -Wl,-soname,libx264.so.54 -lpthreadGC2 -lvfw32 -s
c:\mingw\bin\..\lib\gcc-lib\mingw32\3.3.1\..\..\..\..\mingw32\bin\ld.exe: common/i386/dct-a.o: bad reloc address 0x82 in section `.text'
make: *** [libx264.so.54] Error 1
Administrator@C217 /f/trunk
Thank you for telling me the way to build x264.
Maybe my computer is ill?
Or my source is wrong?
Where do you download the source?
I download it from:
http://trac.videolan.org/x264/changeset/645/trunk?old_path=%2F&format=zip
Is it able to build?
gruntster
6th April 2007, 13:46
I download the source straight from the x264 SVN repository using TortoiseSVN (http://tortoisesvn.tigris.org/). However, the source code you're using compiles fine on my system too.
I think the problem is that you need a newer GCC. You'll probably need at least version 3.4. It looks like you're using 3.3.1. To check, run gcc --version through MSYS.
I'd recommend downloading the latest MinGW packages (binutils-2.16.91-20060119-1.tar.gz, gcc-core-3.4.2-20040916-1.tar.gz, gcc-g++-3.4.2-20040916-1.tar.gz, mingw-runtime-3.12.tar.gz, mingw-utils-0.3.tar.gz and w32api-3.9.tar.gz) from here: http://sourceforge.net/project/showfiles.php?group_id=2435. Extract them all to a fresh MinGW folder and try again.
snow_xmas
6th April 2007, 15:19
And the "warning"s made the compiling become so imperfect. How could make these "warning"s disappear?
gruntster
6th April 2007, 15:22
The warnings are normal and harmless. Errors are the ones you need to worry about. :)
Did you get a successful build?
snow_xmas
6th April 2007, 15:37
No, I haven't. But it isn't so far.
When some of video format compile in avisynth script(e.g. RMVB,WMV),the video stream and audio stream will be out-of-step. And some of video(e.g. movie in PS CD) can't compile in avisynth script. But some softs can convert it to avi. So the CLI is not so useful in some case. This is why I hope to compile the VFW encoder.
snow_xmas
7th April 2007, 06:44
Build x264 Successfully. Thanks everybody who give me help!
The size of "x264.exe" is 531 KB, and "x264vfw.dll" is 546 KB. Is it too small?
snow_xmas
7th April 2007, 07:26
But there is also a problem.
Maybe the file I've be built can't support "pthread". If I input "./configure --enable-pthread",CLI can be built but vfw is impossible to be built.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.