1

I am trying to compile a library, liblo. I am installing it because it is a required library for another library that I am trying to install, osc-mex. In order for liblo to work with osc-mex on Windows, I need to compile liblo with "pthreads commented out".

As far as I can tell from reading around, pthread is a protocol used with Unix? In any event, I need to remove mentions of pthread in the liblo code. But I'm presented with a problem; there are multiple regions of the code that has 'pthread' mentioned. Searching the (uncompiled) source of the liblo directory for the text "pthreads" yields 25 results in eight files:

Filename    Line #  Line text
*********************************************************************************
ChangeLog   165     * Fixed pthread resource leak, when stopping thread
NEWS        153     * Fixed pthread resource leak, when stopping server
config.h.in 18      /* Define to 1 if you have the `pthread' library (-lpthread). */
config.h.in 19      #undef HAVE_LIBPTHREAD
configure   11000   { echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5
configure   11001   echo $ECHO_N "checking for pthread_create in -lpthread... $ECHO_C" >&6; }
configure   11002   if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then
configure   11006   LIBS="-lpthread  $LIBS"
configure   11020   char pthread_create ();
configure   11024   return pthread_create ();
configure   11047   ac_cv_lib_pthread_pthread_create=yes
configure   11052   ac_cv_lib_pthread_pthread_create=no
configure   11059   { echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_create" >&5
configure   11060   echo "${ECHO_T}$ac_cv_lib_pthread_pthread_create" >&6; }
configure   11061   if test $ac_cv_lib_pthread_pthread_create = yes; then
configure   11063   #define HAVE_LIBPTHREAD 1
configure   11066   LIBS="-lpthread $LIBS"
configure.ac43      AC_CHECK_LIB([pthread], [pthread_create])
liblo.pc.in 9       Libs: -L${libdir} -llo -lpthread
libtool     4511    # Do not include libc_r directly, use -pthread flag.
libtool     4536    -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
libtool     5030    -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
ltmain.sh   4027    # Do not include libc_r directly, use -pthread flag.
ltmain.sh   4052    -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
ltmain.sh   4546    -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)

Obviously, some of the above lines are already comments, but there are also lines here which could be modified in many different ways to achieve the same aim. The instruction to "comment out pthreads" is something I don't entirely understand or know how to implement. Any advice would be appreciated.

Shai
  • 111,146
  • 38
  • 238
  • 371
CaptainProg
  • 5,610
  • 23
  • 71
  • 116
  • I assume you're using the configure script on Windows as well; if so, does `./configure --help` present you with an option to disable use of pthreads? – Michael Foukarakis Feb 14 '13 at 11:32
  • Can you please add as a footnote that this question is related to [this one](http://stackoverflow.com/questions/14853603/unable-to-compile-mex) and [this one](http://stackoverflow.com/questions/14789656/linking-matlab-to-a-dll-library)? – Shai Feb 14 '13 at 11:52
  • 1
    There is a version of pthreads that is compatible with Windows. If you have that installed, then you don't need to re-configure liblo to not use it. – Neil Feb 14 '13 at 13:14
  • @Neil can you provide a pointer to that version of pthreads? – Shai Feb 14 '13 at 13:16
  • Pthreads for Windows: http://www.sourceware.org/pthreads-win32/ – Neil Feb 14 '13 at 13:22

2 Answers2

3

The linked instructions for osc-mex refer to a version of liblo several years old. Currently the git version of liblo is supposed to compile on Windows (with MingW) without changes. pthread is now optional. It detects whether pthread is available and "comments it out" for you if it's not.

Steve
  • 8,153
  • 9
  • 44
  • 91
0

Lines 18 and 19 in config.h.in file seems to have a constant HAVE_LIBPTHREAD that indicates the presence/absence of pthread library.

Have you tries to compile the code with HAVE_LIBPTHREAD not defined?

Shai
  • 111,146
  • 38
  • 238
  • 371
  • Thanks Shai. I've commented this out and tried compiling again. The problem is, I don't know if this has worked or not - the original problem I was having was in the compilation of osc-mex in MATLAB. This continues to fail even with your solution implemented, and I don't know whether this is due to either liblo not being compiled properly, or if it's due to some other issue. This is proving to be very difficult! – CaptainProg Feb 14 '13 at 15:27
  • @CaptainProg - you are learning a lot through this process, so be strong! (1) please verify that you have lib or a dll library compiled correctly from liblo. You might want to examine the library file using [dependancy walker](http://www.dependencywalker.com/). (2) in matlab, try compiling (mexing) with '-v' to have verbose information. See what the problems are there. – Shai Feb 14 '13 at 15:52