-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static pthreads-win32 causes core/mplayer.c to fail compilation #6
Comments
First off, calling these attach functions is required if pthread-w32 is used when doing static linking. Though it looks like a newer version might make that optional. The latest release seems to have a bug associated with that, but the CVS version might be fine. The configure test should catch this. It tries to compile a test program using these attach functions, and if that fails, use of pthreads is disabled. Also, pthread.h should always define this, as long as _POSIX_C_SOURCE is defined to something recent (I didn't check if that's still the case with newer pthread-w32 versions). On my Linux system, it's automatically defined to 200809 by the compiler (because we use --std=gnu99). So I'm not sure what's going wrong here, and why the configure test even succeeds. Can you post your config.log? |
Also, has this been always the case, or is it a regression? |
I'm not sure if it's a regression. I've experienced it since I first attempted to cross-compile mpv, but considering that I only found out about mpv ~3 weeks ago I can't really say if it used to work. I'd never managed to compile MPlayer2 under MinGW due to a lot more build errors, but I'd only realized very very shortly before finding mpv that I was still attempting to build a revision from June. Since mpv was up-to-date and built easily with MinGW, I never attempted another MinGW build of MPlayer2. I wouldn't be surprised if it's something I did wrong during pthreads' setup, or if the build is a tad too old (I usually only build it after I do a fresh OS upgrade, so the build is from October 25th). from a fresh clone of mpv-player/mpv.git during configure: Checking for pthread ... ./configure: 1498: test: -lpthreadGC2: unexpected operator yes CC core/m_struct.o CC core/mp_common.o CC core/mp_fifo.o CC core/mp_msg.o CC core/mplayer.o core/mplayer.c: In function 'detach_ptw32': core/mplayer.c:4308:5: error: implicit declaration of function 'pthread_win32_thread_detach_np' [-Werror=implicit-function-declaration] core/mplayer.c:4309:5: error: implicit declaration of function 'pthread_win32_process_detach_np' [-Werror=implicit-function-declaration] core/mplayer.c: In function 'osdep_preinit': core/mplayer.c:4329:5: error: implicit declaration of function 'pthread_win32_process_attach_np' [-Werror=implicit-function-declaration] core/mplayer.c:4330:5: error: implicit declaration of function 'pthread_win32_thread_attach_np' [-Werror=implicit-function-declaration] cc1: some warnings being treated as errors make: *** [core/mplayer.o] Error 1 config.log: |
I was quite puzzled at first, but then I found mplayer.c doesn't even #include the pthread header. Can you try this patch: diff --git a/configure b/configure index d314141..5d2b23b 100755 --- a/configure +++ b/configure @@ -1495,7 +1495,7 @@ cc_check $_ld_tmp -DPTW32_STATIC_LIB && (tmp_run || test "$_ld_static") && _ld_p fi fi if test "$_pthreads" = yes ; then - test $_ld_pthread && res_comment="using $_ld_pthread" + test "$_ld_pthread" && res_comment="using $_ld_pthread" def_pthreads='#define HAVE_PTHREADS 1' def_threads='#define HAVE_THREADS 1' extra_cflags="$extra_cflags $THREAD_CFLAGS" diff --git a/core/mplayer.c b/core/mplayer.c index 04ea0e2..2d58689 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -22,6 +22,10 @@ #include #include +#ifdef PTW32_STATIC_LIB +#include +#endif + #include #include |
The patch as posted fails to patch to core/mplayer.c because the #includes are bare. But I applied it manually and pointed it at pthread.h, and compilation now succeeds. The binary is also larger, so it does appear that libpthreadGC2 did get linked in. |
Oh, sorry, github messes it up when displaying it on the website. Yes, it's meant to "#include <pthread.h>". Thanks for testing. I'll push the patch to master at some later time. |
Currently I've been getting around this by using --disable-pthreads when I cross-compile for Windows. Using MinGW-w64 GCC 4.7.2, I'd built pthreads-win32 from CVS using the GC-static option.
The text was updated successfully, but these errors were encountered: