2014-07-15 32 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以使用舊的語義進行內聯,並修復了問題。