Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Programming and Hacking > Development
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 10th July 2012, 20:04   #1  |  Link
sirt
x264 fan
 
sirt's Avatar
 
Join Date: Feb 2011
Location: In the trap
Posts: 458
Compile x264 on win 32

Hello,

As I am a perfect noob at compiling x264 for win32, I come with some questions to understand much more what I am doing. First of all, I get the source from there :

http://www.videolan.org/developers/x264.html

Then I save the x264 folder to C:\

I decided to follow that tutorial right there :

http://mediaretriever.blogspot.fr/20...n-windows.html

I followed it step by step and I ended with the "x264.exe" on my top x264 folder demuxed before to C:\ ; but something is unclear to me : the exe created is only 1.50 MB ! Is that normal ? I would have expected it to be 9.8 Mb like the latest one you can download from www.x264.nl ; then, what am I doing wrong ? I guess I should add some diff patches somewhere but I ignore how and from where to get them (excepted Komisar page)
sirt is offline   Reply With Quote
Old 10th July 2012, 20:30   #2  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
x264 can be built-with optional libraries, such as libavcodec/libavformat and ffms2. You probably have built your binary without these, which explains why it's much smaller.

As long as you don't need the built-in libav/ffms2 support, that should be no problem at all. Otherwise you'll have to put the missing libraries in place and re-built x264. The configure script will find and enable them automatically.

BTW: If you don't want to compile those libraries yourself, Komisar provides a quite useful "libpack" for building x264
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 10th July 2012, 20:51   #3  |  Link
sirt
x264 fan
 
sirt's Avatar
 
Join Date: Feb 2011
Location: In the trap
Posts: 458
Thanks Lord, and sorry for having posted this in the wrong place.

But how would you "put the missing libraries in place and re-built x264" ? Should I download some patch (diff files ?) and create a sub folder called "patch" on my top x264 source folder for example ? I am surely dumb but I have no idea what these diff refer to and how to compile x264 with the method described below.

Are you referring to the "x264 libpack" section on Komisar page ? Let's say I get that : http://komisar.gin.by/mingw/libpack-gcc44x-20120119.7z ; I have any idea what to do with that (again, where to incoparate those folders in order to compile everything with the method below)

Moreover, I don't understand either what are the "precompiled toolchains" either, how to choose one and how to use/compile them.
sirt is offline   Reply With Quote
Old 10th July 2012, 20:59   #4  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
You don't need any patch to add the missing libraries. The official x264 supports these out-of-the-box.

As said before, the optional libraries will be detected and enabled by the ./configure script, if they are available. Just put the .lib files into your "lib" directory and put the corresponding header files into your "include" directory.

Alternatively you may add --extra-cflags="-I<path_to_additional_header_files> -L<path_to_additional_lib_files>" to your call of the ./configure script - if you don't want to add the files to your global "lib" / "include" folder.

BTW: You can always check the output of ./configure to see which libraries have been found/enabled.
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 10th July 2012 at 21:05.
LoRd_MuldeR is offline   Reply With Quote
Old 10th July 2012, 22:00   #5  |  Link
sirt
x264 fan
 
sirt's Avatar
 
Join Date: Feb 2011
Location: In the trap
Posts: 458
Well I've copied both "lib" and "include" foloders to the top x264 folders downloaded from videolansource, then I followed the tutorial ; everyhting
worked well, excepted that the fact the lib and include folders seem not to have been taken in account !

In MINGW32 I tried something like : make --extra-cflags="-I<"c:\x264\include"> -L<"c:\x264\lib">" but it doesnt seem to work either (I still get the 1.50 mb file) ; it says something is ignored. Well, as you try to explain to me, it is certainly simple but I keep on doing something wrong.
sirt is offline   Reply With Quote
Old 10th July 2012, 22:07   #6  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Try the following:
./configure --extra-cflags="-I/c/x264/include -L/c/x264/lib"

Given you have put the suitable .lib files into "c:\x264\lib" and the corresponding header files into "c:\x264\include".

If ./configure still won't find the desired libraries, check your config.log
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 11th July 2012, 20:53   #7  |  Link
sirt
x264 fan
 
sirt's Avatar
 
Join Date: Feb 2011
Location: In the trap
Posts: 458
It seems what you told me to do works but I still end with a 1.50 MB file ! Let me explain you what I exactly do :

1) I have gotten git and I open "Git Batch" where I type :

git clone git://git.videolan.org/x264.git "C:/x264"

All the source code is then copied to C:\x264

2) I have no idea what I should choose there http://komisar.gin.by/mingw/index.html ; then I decided to get that http://komisar.gin.by/mingw/libpack-gcc47x-20120620.7z (x264 libpack GCC 4.7.x)

I create an empty "lib" and "include" folder under "x264"

3) Behind that libpack there too folders "i686-w64-mingw32" and "x86_64-w64-mingw32" ; I choose the second one ; there are two sub folders : "include" that contains one billion .h files and "lib" which gathers only .a files. I copied both folders to my x264 top folder then used :

./configure --extra-cflags="-I/c/x264/include -L/c/x264/lib"

(On MinGW Shell)

Then : make

It works but I still end with the 1.50 MB file ! It is probably not surprising as much as I don't have any .lib files anywhere. Am I maybe wrong at downloading those libpacks ? Should I download a "precompiled chains" ?

It looks like I would not understand whatever you can tell me, so an example would be welcomed if you are enough courageous to !

Let's say you start with "c:\x264" , how would you proceed then step by step to compile x264 with some libraies like I intend to (trough MinGW Shell) ?
sirt is offline   Reply With Quote
Old 11th July 2012, 21:08   #8  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
If you are building a 32-Bit binary (using the 32-Bit MinGW/GCC compiler), which you probably are, then you need the 32-Bit libraries, from the "i686-w64-mingw32" folder of the libpack. The "x86_64-w64-mingw32" folder is for 64-Bit.

There is no need to create the "lib" and "include" folders inside the x264 source folder. It's kind of unusual, but nevertheless should work - as long as you specify the paths properly.

Let's assume you have put the library (.a) files into "C:\libpack\lib" and the corresponding header (.h) files into "C:\libpack\include", then the proper command would be: ./configure --extra-cflags="-I/c/libpack/include -L/c/libpack/lib"

Also note that if the libpack has some header (.h) files inside "...\include\some_subfolder" they need to go into "C:\libpack\include\some_subfolder" on your HDD too. The original directory structure within "include" must be retained.

Last but not least: Next time look at your config.log after you ran ./configure in order to find out what exactly went wrong! This will be much easier than having us guess what went wrong
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 11th July 2012 at 21:19.
LoRd_MuldeR is offline   Reply With Quote
Old 11th July 2012, 22:00   #9  |  Link
sirt
x264 fan
 
sirt's Avatar
 
Join Date: Feb 2011
Location: In the trap
Posts: 458
Thanks Lord.

I did what you asked for :

I keep the x264 source on "c:\x264"

I've got "libpack-gcc47x-20120620" and copied "include" and "lib" to the created folder "c:\libpack"

Then this is what I've typed on MinGW Shell :



I don't know if the message dealing with "gpac too old" can provoke errors or not and I have no idea what that gpac is either.

Then I type "make" and the compiling process begins and I end again with my 1.5 MB file !!

Here are screenshot of the process that I guess is incorrect :


sirt is offline   Reply With Quote
Old 11th July 2012, 22:24   #10  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
It seems that x264's configure script has detected an outdated revision of the GPAC library.

Komisar's libpack should contain a suitable version. So are you 100% sure there isn't another (older) version floating around on your system somewhere?

The "lib" and "include" folders inside your MinGW installation folder would be the primary places to check...

(As for lavf and ffms2: They have not been detected. I already told you where you can find more information on what exactly went wrong)
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 11th July 2012, 22:45   #11  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Sorry, after thinking about it a bit more, I think we need:

./configure --extra-cflags="-I/c/libpack/include" --extra-ldflags="-L/c/libpack/lib"

BTW: You said you picked Komisar's libpack for GCC 4.7.x. What version of GCC are you using? Typing "gcc -v" will tell you.
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 11th July 2012 at 22:58.
LoRd_MuldeR is offline   Reply With Quote
Old 12th July 2012, 10:01   #12  |  Link
sirt
x264 fan
 
sirt's Avatar
 
Join Date: Feb 2011
Location: In the trap
Posts: 458
Thanks for your help again.

Then how can I delete the current GPAC library and update it ?

I've tried gcc -v in minGW shell and it told me which GCC i should choose so I downloaded this :

http://komisar.gin.by/mingw/libpack-...to-20120620.7z

Then, again I got x264 source, place it under "c:\x264" and under "c:\libpack" I placed the "include" and "lib" folders from the previous download without changing anything

I opened minGW and type cd "c:\x264", then ./configure --extra-cflags="-I/c/libpack/include" --extra-ldflags="-L/c/libpack/lib"

And..I still get the 1.50 mb file. I PMed you my log because I don't really understand what happens even though it is clear some errors occur.
sirt is offline   Reply With Quote
Old 13th July 2012, 08:23   #13  |  Link
sirt
x264 fan
 
sirt's Avatar
 
Join Date: Feb 2011
Location: In the trap
Posts: 458
Then did you have a look at my log ?
sirt is offline   Reply With Quote
Old 14th July 2012, 11:14   #14  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
I was busy with "real life" stuff. But I just had a quick look at your log and it seems various symbols are missing!

As far as I can tell, these are functions that normally should be included in MinGW/GCC itself (e.g. "__mingw_vsscanf") , so I guess your MinGW/GCC somehow is broken or "incompatible" with Komisar's lib pack.

I'd suggest to download "GCC 4.7.x" or whatever version your prefer directly from Komisar's site.

Then extract it into "C:\MinGW.komisar", so that "C:\MinGW.komisar\bin\gcc.exe" exists. After that, open your MSYS (MinGW) shell (console) and type the following commands:

Code:
umount /mingw
mount c:/MinGW.komisar /mingw
If you then type only "mount" without a parameter, you should now see something like that:

Code:
C:\Users\YourName\AppData\Local\Temp on /tmp type user (binmode,noumount)
c:\MSYS\msys\1.0 on /usr type user (binmode,noumount)
c:\MSYS\msys\1.0 on / type user (binmode,noumount)
c:\MinGW.komisar on /mingw type user (binmode)
c: on /c type user (binmode,noumount)
d: on /d type user (binmode,noumount)
e: on /e type user (binmode,noumount)
f: on /f type user (binmode,noumount)
g: on /g type user (binmode,noumount)
h: on /h type user (binmode,noumount)
i: on /i type user (binmode,noumount)
j: on /j type user (binmode,noumount)
k: on /k type user (binmode,noumount)
Also try to type "gcc -v" to make sure that the new MinGW/GCC really is working as expected. It should say:

Code:
gcc version 4.7.1 (multilib.generic.Komisar) (GCC)
Finally try again with this command from x264 source directory:

Code:
./configure --extra-cflags="-I/c/libpack/include" --extra-ldflags="-L/c/libpack/lib"
make -B
Still assuming the libpack is at "C:\libpack" and matches your new MinGW/GCC version...
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 14th July 2012 at 13:14.
LoRd_MuldeR is offline   Reply With Quote
Old 14th July 2012, 20:01   #15  |  Link
sirt
x264 fan
 
sirt's Avatar
 
Join Date: Feb 2011
Location: In the trap
Posts: 458
Thank you for this detailed help.

I followed exactly what you asked and it is better because...I end with a 1.61 MB file ! I guess there are still errors so I uploaded the log and PMed it to you again.

I don't understand the problem because let's sum up what I did :

1) I got last x264 source code via git Bash and place it to "c:\x264"

2) I opened MinGW shell, typed gcc -v and it says gcc 4.6.2. So I went to komisar and downloaded the corresponding "procompiled chain" and "x264 libpack" (both GCC 4.6.x)

3) I extracted the "precompiled chain" to "c:\MinGW.komisar" and it contains "bin" (including the gcc.exe), doc, i686-w64-mingw32 (a sub filder that also contains bin, include, lil, lib64) , lib and libexec ; I added "yasm.exe" to "c:\MinGW.komisar\bin"

4) I extracted to "c:\libpack" both include and lib with all the three .tag files from the "x264 libpack" downloaded at step 2.

5) I finally followed the steps from your last post.

As I obtain a 1.61 MB, it looks like, at least, something has been added during the compilation.

EDIT : I did exactly the same thing with gcc 4.7 and came up with a 1.71 mb file this time lol...I pmed you the log again. I precise I installed and download that version of MinGW : http://sourceforge.net/projects/ming...6.exe/download

Last edited by sirt; 14th July 2012 at 22:07.
sirt is offline   Reply With Quote
Old 15th July 2012, 14:09   #16  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
You really should start reading the log

Quote:
Failed commandline was:
--------------------------------------------------
gcc conftest.c -m32 -Wall -I. -I$(SRCPATH) -march=i686 -mfpmath=sse -msse -std=gnu99 -lswscale -lavutil -m32 -Wl,--large-address-aware -lpthread -o conftest
conftest.c:1:32: fatal error: libswscale/swscale.h: No such file or directory
compilation terminated.
Obviously this time the header file(s) could not be found

Make sure that "C:\libpack\include\libswscale\swscale.h" (and all the others) do exist and that you are adding the proper --extra-cflags="-I/c/libpack/include" to your ./configure call.

BTW: It is not surprising that the size of the binary differs slightly between different GCC versions. This alone doesn't tell anything about which libraries have been included (or not).

The output of ./configure does:

Code:
platform:      X86
system:        WINDOWS
cli:           yes
libx264:       internal
shared:        no
static:        no
asm:           yes
interlaced:    yes
avs:           yes
lavf:          no
ffms:          no
gpac:          no
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 15th July 2012 at 14:18.
LoRd_MuldeR is offline   Reply With Quote
Old 15th July 2012, 15:03   #17  |  Link
sirt
x264 fan
 
sirt's Avatar
 
Join Date: Feb 2011
Location: In the trap
Posts: 458
Thanks again for your answer. I kept on trying more and more and I finally ended with a 13 MB file and this happened when "include" and "lib" are the same on "c:\MinGW.komisar" and "c:\libpack" but unfortunately the log still seem to contain errors. Then I've uploaded the given x264.exe + log but I have no idea if you can know from this if it is almost correct (I mean : can you know from the exe if I've really added the libraries ?)

http://www.sendspace.com/file/xsa0a8

Well, as I see from the log such and such files are sitll not found even though I have them, I guess I will have to try until it is perfect.

Despite everything, there is still something obscur to me : let's say I encode a video with the 1.5 MB file compiled without any libraries and this last 13 MB file. What will be obviously different ? More precisely, I have no idea what such and such libraries added will change and in what way compiling them will be usefull or improve anything.

Finally how could I compile a patch like that one http://komisar.gin.by/old/2200/p/x26...comp.1936.diff or any given patch ? You said something like it would be easier to work with precompiled chains and not diff but I don't understand why.
sirt is offline   Reply With Quote
Old 15th July 2012, 15:13   #18  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Well, the "configure" script tries out various things in order to figure out what does work in your current build environment and what does not.

Not every single test needs to run through cleanly. If something fails, this will only tell the configure script that this "feature" cannot be used in your build environment.

As long as the final result is "okay" (i.e. all libraries you want to have included have been found/enabled), you don't need to bother

And your result looks good now:
Code:
platform:      X86
system:        WINDOWS
cli:           yes
libx264:       internal
shared:        no
static:        no
asm:           yes       <- we have YASM, i.e. x264 won't run in "super slow" mode
interlaced:    yes
avs:           yes
lavf:          yes       <- we have built-in LAVF input
ffms:          yes       <- we have built-in FFMS2 input
gpac:          yes       <- we have built-in MP4 output
gpl:           yes
thread:        posix     <- we have pthreads, i.e. multi-threading will be enabled
BTW #1: You may want to add --enable-strip in order to strip the debug symbols, which reduces the size of the binary.

BTW #2: You may want to include -march=core2 (or whatever your CPU is) into the --extra-cflags="..." to get a (potentially) slightly faster binary.

BTW #3: If you don't already do that, you may want to run "make fprofiled VIDS=sample.avs" instead of only "make", which again might result in a slightly faster binary.

(Note that "sample.avs" needs to exist in the current folder and should output a short video sequence. I'd use foreman or something like that)
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 15th July 2012 at 16:28.
LoRd_MuldeR is offline   Reply With Quote
Old 15th July 2012, 15:34   #19  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by sirt View Post
Finally how could I compile a patch like that one http://komisar.gin.by/old/2200/p/x26...comp.1936.diff or any given patch ? You said something like it would be easier to work with precompiled chains and not diff but I don't understand why.
Patches modify the source code and maybe also the make/configure files.

Thus you have to apply the patch before you do anything else. Usually a "patch -p1 < something.diff" should do the job.

But be aware: Patches are usually made for a specific revision of x264. Whether they work with other revisions is not guaranteed at all!

Even if the "patch" command runs through cleanly, the patch may not work as expected when applied on a "wrong" revision.


BTW: The term "build chain" refers to all the tools that are involved in building a program. This includes the compiler, the linker, the Make program and so on.

If you download a MinGW/GCC package that works "out of the box" (like the one provided by Komisar), then it's pre-compiled - as you did not compile MinGW/GCC from the sources yourself.

After all you will always have to use a pre-compiled MinGW/GCC at some point, even if you want to compile MinGW/GCC yourself ("chicken or egg" paradoxon).
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 15th July 2012 at 15:53.
LoRd_MuldeR is offline   Reply With Quote
Old 15th July 2012, 16:52   #20  |  Link
sirt
x264 fan
 
sirt's Avatar
 
Join Date: Feb 2011
Location: In the trap
Posts: 458
Okay, thanks for the time spent to help me with that stuff. I will keep on experimenting by myself.

According to you what is the point of compiling x264 yourself ? I know one's version will differ from someone else version by the different patches applied but I think some patches are somehow interesting : like that one for example http://komisar.gin.by/old/2200/p/x264_aq3.diff which in my opinion is some kind of modified aq-mode, included on x264 TMod. In fact, it looks like official x264 features concocted with x264 kMod or x264 Tmod are pretty enough, aren't they ? As much as my gait is purely experimental, I don't understand in which way compiling yourself x264 will be "better" than downloading one of those compiled version listed before. Withal, do you think some people simply create patches by themselves and compile them afterwards ? Otherwise, I think it is enough to stick with official or Mod versions in so far as the used patches are avaible to everyone.
sirt is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:39.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.