【问题标题】:ImageMagick pthread.h multiple definitionImageMagick pthread.h 多重定义
【发布时间】:2014-09-06 06:19:40
【问题描述】:

当尝试编译更新版本的 ImageMagick(v6.8.7-2 或更高版本,v6.8.7-1 很好)时,我得到了一堆:

CCLD     magick/libMagickCore-6.Q16.la
magick/.libs/magick_libMagickCore_6_Q16_la-animate.o: In function `__pthread_cleanup_routine':
/usr/include/pthread.h:581: multiple definition of `__pthread_cleanup_routine'
magick/.libs/magick_libMagickCore_6_Q16_la-accelerate.o:/usr/include/pthread.h:581: first defined here
magick/.libs/magick_libMagickCore_6_Q16_la-annotate.o: In function `__pthread_cleanup_routine':
/usr/include/pthread.h:581: multiple definition of `__pthread_cleanup_routine'
magick/.libs/magick_libMagickCore_6_Q16_la-accelerate.o:/usr/include/pthread.h:581: first defined here
magick/.libs/magick_libMagickCore_6_Q16_la-artifact.o: In function `__pthread_cleanup_routine':
/usr/include/pthread.h:581: multiple definition of `__pthread_cleanup_routine'
magick/.libs/magick_libMagickCore_6_Q16_la-accelerate.o:/usr/include/pthread.h:581: first defined here
magick/.libs/magick_libMagickCore_6_Q16_la-attribute.o: In function `__pthread_cleanup_routine':
/usr/include/pthread.h:581: multiple definition of `__pthread_cleanup_routine'
magick/.libs/magick_libMagickCore_6_Q16_la-accelerate.o:/usr/include/pthread.h:581: first defined here
... goes on for quite a bit longer, all the same.

/usr/include/pthread.h(来自 glibc-headers 2.5-118.el5_10.2)的相关区域是:

/* Function called to call the cleanup handler.  As an extern inline
function the compiler is free to decide inlining the change when
needed or fall back on the copy which must exist somewhere else.  */

extern __inline void
__pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame)
{
  if (__frame->__do_it) // <======= this is :581
    __frame->__cancel_routine (__frame->__cancel_arg);
}

我一直在 ImageMagick 的论坛上发帖,但没有任何回应。

即使您不能确切地说出发生了什么,我如何开始确定问题出在 ImageMagick 还是 pthread.h 上?我从那里去哪里?

grep pthread_cleanup_routine -r * 只显示与二进制对象文件的匹配——ImageMagick 的源代码中没有一个包含 pthread_cleanup_routine。当然,其中一些来源包括“pthread.h”。

这让我相信这是一个 glibc 问题,而不是 ImageMagick 问题……但同样,ImageMagick 的早期版本编译得很好。 (我已经区分了它破坏的版本之间的 svn 源代码。很多配置/makefile 更改,但没有什么让我知道它为什么会导致这种情况。)

我在 CentOS 5 上,内核 2.6.18-308.24.1.el5,gcc v4.9.0,ld v2.24,glibc-headers 2.5-118.el5_10.2

【问题讨论】:

    标签: c++ c pthreads imagemagick glibc


    【解决方案1】:

    我在使用较新的 gcc 编译器 (4.9.3) 时遇到了这个错误

    ImageMagick(6.8.9_7) 配置脚本正在检查编译器是否支持 gnu99 标准。如果是,则配置脚本将标准设置为 gnu99 并启用 openmp。

    内联语义随着 C 标准 gnu99 的变化导致外部内联函数的多个定义 https://gcc.gnu.org/onlinedocs/gcc-4.9.3/gcc/Inline.html#Inline.

    所以,我添加了编译器标志 -fgnu89-inline 以使用旧语义进行内联,它解决了这个问题。

    【讨论】:

      【解决方案2】:

      我看到很多人发布了与 ImageMagick 以外的其他软件包类似的问题。希望其他人会发现这很有用。

      在 __pthread_cleanup_routine 之前更改 pthread.h:

      extern __inline void
      

      if __STDC__VERSION__ < 199901L
      extern
      #endif
      __inline void
      

      解决了这个问题。旧版本的 glibc 在使用 -fexceptions 时会出现问题,并且内联非 C99 一致性(请参阅http://gcc.gnu.org/ml/gcc-patches/2006-11/msg01030.html。)最近的 glibc 也会解决这个问题,但这对于那些不想这样做的人来说应该是一个临时修复/ 不应该升级它。

      ImageMagick svn 13539(后来成为 v6.8.7-2)开始使用 -fexceptions。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2022-01-09
        • 1970-01-01
        • 1970-01-01
        • 2021-12-14
        • 1970-01-01
        • 2017-07-16
        相关资源
        最近更新 更多