[FFmpeg-devel] [PATCH] pthread detection on mingw + static pthread

Gianluigi Tiesi mplayer
Tue Apr 22 21:47:29 CEST 2008


This patch makes configure script detect pthreads win32 on mingw

first it tries to link directly if it fails
it tries by adding -lws2_32 this means that pthread lib is
static compiled, in this case a define is needed (and added)

also x264 if compiled with the same pthread lib needs extralibs
to compile, anyway it seems that libx264 needs stdint.h inclusion

there is a patch for ffmpeg.c to handle pthread static,
it's needed also for other executables using pthreads
I don't use/compile ffserver / ffplay so I have no clue
but adding the same fix on them should be strightforward

Currently I've only tested detection for static pthread
but it should be fine also with pthreadGC2.dll + .a

Regards

-- 
Gianluigi Tiesi <sherpya at netfarm.it>
EDP Project Leader
Netfarm S.r.l. - http://www.netfarm.it/
Free Software: http://oss.netfarm.it/
-------------- next part --------------
Index: configure
===================================================================
--- configure	(revision 12924)
+++ configure	(working copy)
@@ -1593,6 +1593,11 @@
     elif check_func pthread_create -pthreads; then
         add_cflags -pthreads
         add_extralibs -pthreads
+    elif check_func pthread_create -lpthreadGC2; then
+        add_extralibs -lpthreadGC2
+    elif check_func pthread_create -DPTW32_STATIC_LIB -lpthreadGC2 -lws2_32; then
+        add_cflags -DPTW32_STATIC_LIB
+        add_extralibs -lpthreadGC2 -lws2_32
     elif ! check_lib pthread.h pthread_create -lpthread; then
         die "ERROR: can't find pthreads library"
     fi
@@ -1629,7 +1634,7 @@
 enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
 enabled libtheora  && require  libtheora theora/theora.h theora_info_init -ltheora -logg
 enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
-enabled libx264    && require  x264 x264.h x264_encoder_open -lx264 -lm
+enabled libx264    && require2 x264 "stdint.h x264.h" x264_encoder_open -lx264 -lm
 enabled libxvid    && require  Xvid xvid.h xvid_global -lxvidcore
 enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
 
Index: ffmpeg.c
===================================================================
--- ffmpeg.c	(revision 12924)
+++ ffmpeg.c	(working copy)
@@ -3894,11 +3894,25 @@
     { NULL, },
 };
 
+#ifdef PTW32_STATIC_LIB
+void detach_ptw32(void)
+{
+  pthread_win32_process_attach_np();
+  pthread_win32_thread_attach_np();
+}
+#endif
+
 int main(int argc, char **argv)
 {
     int i;
     int64_t ti;
 
+#ifdef PTW32_STATIC_LIB
+  pthread_win32_process_attach_np();
+  pthread_win32_thread_attach_np();
+  atexit(detach_ptw32);
+#endif
+
     avcodec_register_all();
     avdevice_register_all();
     av_register_all();



More information about the ffmpeg-devel mailing list