Pthreads

From FFmpeg on Windows

Jump to: navigation, search

FFmpeg has support for native Win32 threads, but since some libraries use pthreads (like x264), it's preferable to use pthreads.

Go to pthreads-win32.

Get the latest version: download

Unpack it.


You will need to patch pthreads-win32 so it is usable by FFmpeg. There is a bug regarding POSIX compatibility. The patch is here: http://ffmpeg.arrozcru.org/wiki/images/1/12/Pthreads-w32-2-8-0.diff


Go to the folder and run make. You'll receive the following information:

Run one of the following command lines:
make clean GC            (to build the GNU C dll with C cleanup code)
make clean GCE           (to build the GNU C dll with C++ exception handling)
make clean GC-inlined    (to build the GNU C inlined dll with C cleanup code)
make clean GCE-inlined   (to build the GNU C inlined dll with C++ exception handling)
make clean GC-static     (to build the GNU C inlined static lib with C cleanup code)
make clean GC-debug      (to build the GNU C debug dll with C cleanup code)
make clean GCE-debug     (to build the GNU C debug dll with C++ exception handling)
make clean GC-inlined-debug    (to build the GNU C inlined debug dll with C cleanup code)
make clean GCE-inlined-debug   (to build the GNU C inlined debug dll with C++ exception handling)
make clean GC-static-debug     (to build the GNU C inlined static debug lib with C cleanup code)

If you want to use the static libraries, you will have to patch FFmpeg. The patch involves properly detecting the static library in configure and (un)initializing it. http://ffmpeg.arrozcru.org/wiki/images/d/dd/Ffmpeg_r15966_static_pthreads.diff


The pthreads-win32 developers suggest using the shared library.


We'll use the libraries with C cleanup code, since that's all we'll need.

Shared

make clean GC


Copy pthreadGC2.dll to your /lib folder. Copy it again to the /bin folder, so that any executables linked to it can find it. Copy it again to your /lib folder, without the GC2 part. pthread.dll is necessary for the -lpthread flag to find it. pthreadGC2.dll is the actual file that will be needed to run FFmpeg.

cp pthreadGC2.dll /mingw/lib
cp pthreadGC2.dll /mingw/bin
cp pthreadGC2.dll /mingw/lib/pthread.dll


Copy the necessary header files to your /include folder.

cp pthread.h sched.h /mingw/include


configure FFmpeg with --enable-pthreads, make and all should work fine.


Simplified instructions:

tar zxfv pthreads-w32-2-8-0-release.tar.gz
patch -p0 < pthreads-w32-2-8-0.diff
cd pthreads-w32-2-8-0-release
make clean GC
cp pthreadGC2.dll /mingw/lib
cp pthreadGC2.dll /mingw/bin
cp pthreadGC2.dll /mingw/lib/pthread.dll
cp pthread.h sched.h /mingw/include

Static

make clean GC-static


Copy libpthreadGC2.a to your /lib folder.
Copy the necessary header files to your /include folder.


Remember to patch FFmpeg to properly find the static pthreads-win32 library, then configure FFmpeg with --enable-pthreads, make and all should work fine.


Simplified instructions:

tar zxfv pthreads-w32-2-8-0-release.tar.gz
patch -p0 < pthreads-w32-2-8-0.diff
cd pthreads-w32-2-8-0-release
make clean GC-static
cp libpthreadGC2.a /mingw/lib
cp pthread.h sched.h /mingw/include
back
Personal tools