【问题标题】:"Comment out pthreads" to compile a library“注释掉 pthreads”来编译一个库
【发布时间】:2013-02-14 10:50:11
【问题描述】:

我正在尝试编译一个库,liblo。我正在安装它,因为它是我尝试安装的另一个库 osc-mex 的必需库。为了让 liblo 在 Windows 上与 osc-mex 一起工作,我需要使用“pthreads commented out”编译 liblo

据我所知,pthread 是 Unix 使用的协议?无论如何,我需要删除 liblo 代码中对 pthread 的提及。但是我遇到了一个问题;代码中有多个区域提到了“pthread”。在 liblo 目录的(未编译的)源代码中搜索文本“pthreads”会在 8 个文件中产生 25 个结果:

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)

显然,上面的一些行已经是 cmets,但这里也有一些行可以通过多种不同的方式进行修改以达到相同的目的。 “注释掉 pthreads”的指令是我不完全理解或不知道如何实现的。任何建议将不胜感激。

【问题讨论】:

  • 我假设您也在 Windows 上使用配置脚本;如果是这样,./configure --help 是否会为您提供禁用 pthread 使用的选项?
  • 您能否在脚注中添加此问题与this onethis one 相关?
  • 有一个与 Windows 兼容的 pthreads 版本。如果你已经安装了,那么你不需要重新配置 liblo 来不使用它。
  • @Neil 你能提供一个指向那个版本的 pthreads 的指针吗?
  • Pthreads for Windows:sourceware.org/pthreads-win32

标签: c++ c matlab pthreads osc


【解决方案1】:

osc-mex 的链接说明参考了几年前的 liblo 版本。目前git version of liblo 应该在Windows(使用MingW)上编译而无需更改。 pthread 现在是可选的。它会检测 pthread 是否可用,如果不可用,则会为您“退出”。

【讨论】:

    【解决方案2】:

    config.h.in 文件中的第 18 行和第 19 行似乎有一个常量HAVE_LIBPTHREAD,它指示 pthread 库的存在/不存在。

    您是否尝试编译带有HAVE_LIBPTHREAD定义的代码?

    【讨论】:

    • 谢谢谢。我已经对此发表评论并尝试再次编译。问题是,我不知道这是否有效 - 我遇到的原始问题是在 MATLAB 中编译 osc-mex。即使实施了您的解决方案,这仍然会失败,我不知道这是由于 liblo 没有正确编译,还是由于其他问题。事实证明这是非常困难的!
    • @CaptainProg - 你在这个过程中学到了很多东西,所以要坚强! (1) 请确认您有从 liblo 正确编译的 lib 或 dll 库。您可能想使用dependancy walker 检查库文件。 (2)在matlab中,尝试用'-v'编译(混合)以获得详细信息。看看有什么问题。
    猜你喜欢
    • 2017-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-23
    • 2013-01-08
    • 2023-03-16
    • 1970-01-01
    • 2021-08-09
    相关资源
    最近更新 更多