Cross Compile Win32 - How To Guide

Useful and helpful examples and samples that help users compile FFmpeg

Cross Compile Win32 - How To Guide

Postby puck » Thu Mar 08, 2012 2:28 am

I used this to build a Windows 32 bit version of FFMPEG with Lame, FAAC and X264.
and I post it here to take the pressure off Zeranoe from masochists like myself.
It should be read in conjunction with viewtopic.php?f=7&t=71
Lots of good stuff in here.

As I am a complete NEWBIE and masochist, I cannot answer any questions about this process.
I was GENTLY lead by the hand all the way, by Zeranoe.
Another option (which attempts to automate this) is this build script: https://github.com/rdp/ffmpeg-windows-build-helpers

1. Go to http://ffmpeg.zeranoe.com/blog/ and get "MingGW-w64 Build Script 2.8.4"
or a later version

2. In a terminal session run cd ~; pwd
This will give you your userid. in my case "/home/mark".
Replace <userid> in the script below with your userid.

3. Make a folder "mingw" in your Home folder

4. Copy the build script obtained in step 1 to the folder "mingw".

5. Run the script in a terminal session.
If you get "MinGW-w64 has been built without errors. The MinGW-w64 bin directory needs to be
added to the PATH variable so the system can find it, for Win32 this can be done with:
export PATH="$PATH:/home/<userid>/mingw/mingw-w64-i686/bin"
then the build is ok.

6. Install git: run sudo apt-get install git-core from a terminal session
and get the latest versions of Faac, ffmpeg, lame and x264. You will need
to unpack and copy them to your source folder. See below ......

I am using the following directory structure for my builds (downloaded their source to here) .....
home --- source --- faac-1.28
--- ffmpeg
--- lame-3.99.5
--- x264
--- Backup (for source code including ffmpeg)

home --- software --- packages ---win32


7. Its now time to start inflicting pain :-)
Start a terminal session and copy the commands one by one and paste them
into the terminal and run it.

NOTE: the command - make distclean is not required in a fresh build.

REMEMBER TO CHANGE <userid> TO YOUR userid, OBTAINED IN 2 ABOVE !!!!!

=========== start ===========================================================
export PATH="$PATH:/home/<userid>/mingw/mingw-w64-i686/bin"

=========== lame ============================================================
cd
cd source/lame-3.99.5
make distclean

./configure --host=i686-w64-mingw32 --prefix="/home/<userid>/software/packages/win32" --enable-static --disable-shared

make
make install

======== faac ================================================================
cd
cd source/faac-1.28
make distclean

./configure --host=i686-w64-mingw32 --prefix="/home/<userid>/software/packages/win32" --enable-static --disable-shared --with-mp4v2=no

make
make install

======== x264 ================================================================
cd
cd source/x264
make distclean

/home/<userid>/source/x264/configure --host=i686-w64-mingw32 --cross-prefix=i686-w64-mingw32- --prefix="/home/<userid>/software/packages/win32"

make install; make install-lib-dev; make install-lib-static

======= ffmpeg ==============================================================
cd
cd source/ffmpeg
make distclean

PKG_CONFIG_PATH="/home/<userid>/software/packages/win32/lib/pkgconfig" LDFLAGS="-L/home/<userid>/software/packages/win32/lib" CFLAGS="-I/home/<userid>/software/packages/win32/include" /home/<userid>/source/ffmpeg/configure --pkg-config=pkg-config --prefix="/home/<userid>/software/packages/win32" --enable-memalign-hack --arch=x86 --target-os=mingw32 --cross-prefix=i686-w64-mingw32- --enable-libfaac --enable-libx264 --enable-gpl --enable-nonfree --disable-w32threads

make
make install

=========== end of script ======================================================

If all went well you should have 4 folders in home/software/packages/win32
ie.bin, include, lib and share. Copy ffmpeg.exe from the bin folder to your
Windows 32 bit system and test it. Hopefully it will give you years of joy
and happiness, if not, don't shoot the messenger.
Retrace your steps and look for errors in each configure step.
Thats where I found mine (usually in configure for ffmpeg). :oops:
Last edited by rogerdpack on Tue Apr 23, 2013 10:27 pm, edited 2 times in total.
Reason: clarify
Regards,
Mark

(Experience is something you don't get until just after you need it.)
puck
 
Posts: 9
Joined: Fri Jul 08, 2011 5:36 am

Re: Cross Compile Win32 - How To Guide

Postby rogerdpack » Fri May 18, 2012 4:34 pm

If you just want to build ffmpeg (without x264 et al), then you can can follow steps 1-5, then checkout ffmpeg, cd into it, then run

./configure --enable-memalign-hack --arch=x86 --target-os=mingw32 --cross-prefix=i686-w64-mingw32- --pkg-config=pkg-config

and look for the ffmpeg.exe file

ref: http://betterlogic.com/roger/2011/09/ff ... e-windows/
rogerdpack
 
Posts: 1292
Joined: Fri Aug 05, 2011 9:56 pm

Re: Cross Compile Win32 - How To Guide

Postby smartuser20 » Tue Jul 03, 2012 7:09 pm

puck wrote:

If all went well you should have 4 folders in home/software/packages/win32
ie.bin, include, lib and share. Copy ffmpeg.exe from the bin folder to your
Windows 32 bit system and test it. Hopefully it will give you years of joy
and happiness, if not, don't shoot the messenger.
Retrace your steps and look for errors in each configure step.
Thats where I found mine (usually in configure for ffmpeg).


Hi, I followed your directions here, but I ended up with 3 folders. I don't have the "share" folder. Is this ok? Can I just create it? Sorry for my bad English.
Last edited by rogerdpack on Wed Jul 25, 2012 5:49 pm, edited 3 times in total.
Reason: wow impressive spam
smartuser20
 
Posts: 1
Joined: Tue Jul 03, 2012 7:05 pm

Re: Cross Compile Win32 - How To Guide

Postby rogerdpack » Thu Jul 05, 2012 11:26 pm

you might not even need the "share" folder so you'd be ok there...

also NB that the instructions to use --disable-w32threads may be poor instructions:
viewtopic.php?f=5&t=951&p=3837&hilit=slow#p3837

See also this helper script, which also compiles all the dependencies: https://github.com/rdp/ffmpeg-windows-build-helpers
rogerdpack
 
Posts: 1292
Joined: Fri Aug 05, 2011 9:56 pm

Re: Cross Compile Win32 - How To Guide

Postby Maxime » Fri Feb 22, 2013 9:37 am

rogerdpack wrote:See also this helper script, which also compiles all the dependencies: https://github.com/rdp/ffmpeg-windows-build-helpers

Roger, your script is perfect!
I have tried to send you a feedback and ask you some questions but your email addresses (roger-projects_at_googlegroups.com and rogerpack20052_at_gmail.com) reject emails.
As a new member I am not able to use PM, so I would be happy if you could send me a working email...
I recommend everyone to test this script!
Maxime
 
Posts: 1
Joined: Fri Feb 22, 2013 9:17 am

Re: Cross Compile Win32 - How To Guide

Postby rogerdpack » Fri Feb 22, 2013 7:56 pm

Maxime wrote:
rogerdpack wrote:See also this helper script, which also compiles all the dependencies: https://github.com/rdp/ffmpeg-windows-build-helpers

Roger, your script is perfect!
I have tried to send you a feedback and ask you some questions but your email addresses (roger-projects_at_googlegroups.com and rogerpack20052_at_gmail.com) reject emails.
As a new member I am not able to use PM, so I would be happy if you could send me a working email...
I recommend everyone to test this script!


where did you get the rogerpack20052 from? Anyway rogerdpack@gmail.com should work (I hope to have fixed the roger-projects one this morning also, hopefully :)
-r
rogerdpack
 
Posts: 1292
Joined: Fri Aug 05, 2011 9:56 pm

Re: Cross Compile Win32 - How To Guide

Postby Luhps » Mon Mar 11, 2013 9:05 pm

Just thought I'd drop in my two cents in case this helps someone.
I've been playing with this for a while now over the last few days.

Using MinGW + MSYS
I ran the command
Code: Select all
./configure --prefix=ffmpeg/ --arch=x86 --target-os=mingw32 --pkg-config=pkg-config --disable-network --disable-debug --disable-yasm --enable-shared --enable-memalign-hack


This will compile it in such a way as to make it work for Windows QT. One part that had me hung up, and I suppose this is stupid, but "--cross-prefix=SOMEVALUE" I didn't realize this was the prefix to the EXE files, so some worked, and some didn't. I would get errors like "Could not find SOMEV ALUE-ar"

depending on what version of MinGW I had installed. I simply removed it, and added a few other flags, and everything seemed to work just fine. Also, when you run MAKE, grab a cup of coffee, it takes a bit.

In the end, you should see some ".dll.a" files with just the standard ".a" files, the ".dll.a" should work with QT.

ALSO

since QT is for C++ and this is C, to include the libraries, you'll need the following in the the #include area

Code: Select all
extern "C" { // how to include C code in C++ code, fucking-a this is rough.
// FFMPEG is written in C, this is here before the FFMPEG includes to prevent errors
#ifndef INT64_C // Macro - sort of like an inline function
#define INT64_C(c) (c ## LL) //whenever the macro INT64_C(n) is encountered, it will replace (n) for (c ## LL), i do not know what c ## LL does, just pulled it off the web as a solution
#define UINT64_C(c) (c ## ULL)
#endif

#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
}


I'm sort of new to C++, C, Qt, and FFMpeg, but I was able to get this working thanks to this post as one of the last missing aspects. So thanks for that! and you are so right about the Masochism aspect.
Luhps
 
Posts: 3
Joined: Mon Mar 11, 2013 8:51 pm

Re: Cross Compile Win32 - How To Guide

Postby hnraysir » Wed Mar 20, 2013 7:28 am

hnraysir
 
Posts: 5
Joined: Mon Mar 18, 2013 6:06 am

Re: Cross Compile Win32 - How To Guide

Postby hnraysir » Mon Apr 08, 2013 2:03 am

rogerdpack wrote:you might not even need the "share" folder so you'd be ok there...

also NB that the instructions to use --disable-w32threads may be poor instructions:
viewtopic.php?f=5&t=951&p=3837&hilit=slow#p3837

See also this helper script, which also compiles all the dependencies: https://github.com/rdp/ffmpeg-windows-build-helpers


should I remove the option"--disable-w32threads"?
hnraysir
 
Posts: 5
Joined: Mon Mar 18, 2013 6:06 am

Re: Cross Compile Win32 - How To Guide

Postby Zeranoe » Mon Apr 08, 2013 4:22 pm

If you compiled your toolchain using the build script that I provide and you are using pthread-w32 and not winpthread, then you should be disabling w32threads.
User avatar
Zeranoe
Site Admin
 
Posts: 509
Joined: Sat May 07, 2011 7:12 pm

Next

Return to Compiling FFmpeg Examples/Samples

Who is online

Users browsing this forum: No registered users and 1 guest