View Full Version : Cross compiling x264 - is it possible??


ivan_alias
14th January 2005, 16:16
Excuse me for my dumb question..

but is it possible to compile the Win 32 VFW frontend for x264 on a linux system?

I can easily compile mencoder / x264 etc.. and do my encodes on my linux machine no problem, but I don't have any development environment on my Windows machine. Is there a way to do this or am I dreaming and need to goto cygwin or something?

Thanks v much

Doom9
14th January 2005, 17:04
uhh.. compile windows software on a linux environment? Where's the sense in that? considering that since VfW is a windows native API, and that in all likelyhood W32API is used for the VfW frontent, I think your chances are pretty darned slim. Aren't all those tools you can crosscompile based on POSIX and cygwin and Co basically emulate those on W32?

M7S
14th January 2005, 17:29
AFAIK you can crosscompile xvids vfw-frontend so I can't see why the chances has to be that small, but on the other hand I'm no programmer...

Regards,
M7S

ivan_alias
14th January 2005, 17:57
From the XviD sources - below:

Can't see anything similat inthe x264 sources though..



1.d/ Cross compiling xvidcore.
------------------------------

The configure script allows an easy handling of cross compilation. You
have just to specify the host and build platform values.

e.g: building Win32 libxvidcore.dll from a gnu/linux systems
# cd ${xvidcore}/build/generic
# ./configure --host=i386-mingw32 --build=i386-pc-linux-gnu

And then build as usual.

As the example uses the Win32 target, we can even build the vfw frontend.
Additional requirements are:
- Resource compiler (the Makefile uses the syntax of windres from the
GNU CC suite, but you can easily modify the cmd line)
- GNU make (other make programs may have problem with shell expansion)

So to cross compile the VFW frontend, you just need to override the
Makefile variables pointing to the compiler and the resource compiler.
These variables are CC and WINDRES.
# cd ${xvidcore}/vfw/bin
# make CC=i386-mingw32-gcc WINDRES=i386-mingw32-windres

ak
14th January 2005, 18:34
I for one definetly see some sense there, as compiling on windows is painfully slow (I mean mingw) dunno whether it's bash, make or gcc port to blame or both.
It's surely doable, in fact I used to build some DS stuff on linux (for the fun of it :o )

Bogalvator
14th January 2005, 22:03
Why not give it a try?

Use the Makefile in build/cygwin and type
make CC=i386-mingw32-gcc
and then in the vfw/build/cygwin type
make CC=i386-mingw32-gcc WINDRES=i386-mingw32-windres
as it recommends for XviD (obviously replace i386-mingw32-gcc etc with the name of your cross compiler)

ivan_alias
14th January 2005, 23:34
It seems to almost work, but I get a compile error..

/root/x264/vfw/build/cygwin/../../../libx264.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status
make: *** [x264vfw.dll] Error 1

Making my own XviD worked!

Quite amazing really :)

ak
15th January 2005, 00:31
Well, do what it says: 'ranlib libx264.a' :)
Binutils should have prefix as well, so it will be i386-mingw32-ranlib or something

gotaserena
15th January 2005, 01:30
Thanks for the tips! Emerged four packages in gentoo (do -s xmingw to list them) and I was ready.

Really amazing!

ivan_alias
15th January 2005, 11:28
Thanks for the Tip Ak ;)

but still something isnt working for me, I get the same error still.

Has anyone managed this?

Ta'

gotaserena
15th January 2005, 13:09
open x264/build/cygwin/Makefile and:

After
libx264.a: $(DIR_BUILD) $(OBJECTS)
@echo " L: $(@F)"
@cd $(DIR_BUILD) && \
ar rc libx264.a $(OBJECTS) && \
add
$(RANLIB) libx264.a && \

save and make with CC= and RANLIB= set. Then make the vfw as above. It is a good idea to strip the dll after build.

edit: corrected patch on the code. It should work now.

ivan_alias
15th January 2005, 15:25
Thank for persevering with me here, but I'm still doing something wrong :(

My command line is:

make CC=i386-mingw32-gcc RANLIB=i386-mingw32-ranlib

and I'm running it from x264/build/cygwin/

I've altered the section in the Makefile (from x264/build/cygwin/Makefile) so it reads:

libx264.a: $(DIR_BUILD) $(OBJECTS)
@echo " L: $(@F)"
@cd $(DIR_BUILD) && \
$(RANLIB) libx264.a && \
ar rc libx264.a $(OBJECTS) && \
cp -f libx264.a $(DIR_SRC)

The error I'm getting is:

L: libx264.a
i386-mingw32-ranlib: 'libx264.a': No such file
C: ./x264.c
L: x264.exe
libx264.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status
make: *** [x264.exe] Error 1

It seems to not be able to find the libx264.a that's been created in x264/build/cygwin/bin - it's there for sure. Could it be looking for it somewhere else or have I missunderstood this error?

Any ideas?

Thanks for all the help

ak
15th January 2005, 16:13
Originally posted by ivan_alias
I've altered the section in the Makefile (from x264/build/cygwin/Makefile) so it reads:

libx264.a: $(DIR_BUILD) $(OBJECTS)
@echo " L: $(@F)"
@cd $(DIR_BUILD) && \
$(RANLIB) libx264.a && \
ar rc libx264.a $(OBJECTS) && \
cp -f libx264.a $(DIR_SRC)
'Ranlib' goes after 'ar', actually, (ar creates archive, ranlib indexes it)
It should get rid of first error, and hopefully the second too. :)

Hth

gotaserena
15th January 2005, 16:38
Sorry, ivan_alias, I forgot to copy the last line. Ak is right. I've edited my post above so it won't be confusing to someone else.

ivan_alias
15th January 2005, 16:46
It worked for x264.exe :)

but now having similar trouble with the vfw part.

I've tried:

make CC=i386-mingw32-gcc WINDRES=i386-mingw32-windres

and

make CC=i386-mingw32-gcc WINDRES=i386-mingw32-windres RANLIB=i386-mingw32-ranlib

both give the same error:

L: x264vfw.dll
/root/x264/vfw/build/cygwin/../../../libx264.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status
make: *** [x264vfw.dll] Error 1

Looks like the same problem as before, only I can't see where to put that previus line into the Makefile thats in:

/root/x264/vfw/build/cygwin ?

I tried just running ranlib libx264.a at the prompt, didn't seem to work.

Any idea? :) I'm so close!

gotaserena
15th January 2005, 17:00
Strange. You can try:

1) Run ranlib manually on libx264.a in x264/

2) Make clean on everything and try again.

BTW, and OT: anybody knows how to set wine so that the codecs will show up in virtualdub? A link would be great -- I'm lazy to get this thing done...

ivan_alias
15th January 2005, 20:14
Success!

I had 2 versions of ranlib on my system, switched to using the mingw32 one and all is well.


[root@linux cygwin]# locate ranlib
/usr/bin/ranlib
/usr/share/man/man1/ranlib.1.gz
/usr/local/bin/i386-mingw32-ranlib
/usr/local/i386-mingw32/bin/ranlib
/usr/local/man/man1/i386-mingw32-ranlib.1
[root@linux cygwin]# diff /usr/bin/ranlib /usr/local/i386-mingw32/bin/ranlib
Binary files /usr/bin/ranlib and /usr/local/i386-mingw32/bin/ranlib differ

Thanks very much to ak and gotaserena for all your tips - works a treat. So now I can compile xvid and x264 for windows on my sleepy old linux server. I'm no developer, but being able to have the latest versions from CVS and compile them all automatically for windows and linux using a cron job is nice :)

gotaserena
15th January 2005, 20:40
It wouldn't work with the linux ranlib :)

If you are cross-compiling from one machine to the other (as opposed to just use it in the same machine with dual boot), be careful/mindful of the CPU optimizations. Consider adding
CFLAGS += -mtune=i686
or other appropriate tuning (-march, etc.) to your Makefiles.

ivan_alias
15th January 2005, 20:59
It wouldn't work with the linux ranlib

Obvious if you think about it ;)

Optimisation comes now I've got it working!

This compiles are on an old P3 700, so I need to optimise them for my Athlon XP :)