2014-07-15 28 views
1

当试图编译最近的ImageMagick的版本(v6.8.7-2或更高版本,v6.8.7-1是罚款),我收到了一堆:ImageMagick的pthread.h多个定义

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的报头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,kernel 2.6 .18-308.24.1.el5,gcc v4.9.0,ld v2.24,glibc-headers 2.5-118.el5_10.2

回答

1

我见过很多人发布与ImageMagick相似的问题。希望别人会觉得这很有用。

更改pthread.h,只是__pthread_cleanup_routine前:

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。

0

我面对这个错误有一个较新的gcc编译器(4.9.3)

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

内联语义更改为C标准gnu99导致extern内联函数的多重定义 https://gcc.gnu.org/onlinedocs/gcc-4.9.3/gcc/Inline.html#Inline

因此,我添加了编译器标志-fgnu89-inline以使用旧的语义进行内联,并修复了问题。