2013-09-26 21 views
0

我試圖使用GraphicsMagick工具,得到了奇生成錯誤,所以我加了#include <magick/magick.h>使用GraphicsMagick工具C API,未知類型的圖像編譯錯誤

#include <stdio.h> 
int main(int argc, char *argv[]){ 
    printf("hello magick"); 
    return 0; 
} 

正好看到WTF是怎麼回事。顯然hello_world編譯得很好。只需添加magick頭引起噸的錯誤與下列任何的編譯:

  • 鐺或GCC -o test.o $(pkg-config --cflags --libs GraphicsMagick) test.c
  • 鐺或GCC -o test.o $(GraphicsMagick-config --cflags --libs) test.c

從鐺:

zsh/2 1791 % clang -o test.o $(pkg-config --cflags --libs GraphicsMagick) test.c 
In file included from test.c:2: 
/usr/include/GraphicsMagick/magick/magick.h:19:9: error: unknown type name 'Image' 
typedef Image 
     ^
/usr/include/GraphicsMagick/magick/magick.h:20:28: error: unknown type name 'ImageInfo' 
    *(*DecoderHandler)(const ImageInfo *,ExceptionInfo *); 

Hale先生建議的解決方案(#1)完美地工作或測試。嘗試真正的項目; GCC吐出成千上萬像錯誤行:

/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/include/f16cintrin.h: In function ‘__m128i mm256_cvtps_ph(__m256, int)’: /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/include/f16cintrin.h:73:66: error: cannot convert ‘__m256 {aka float}’ to ‘__vector(8) float’ for argument ‘1’ to ‘__vector(8) short int __builtin_ia32_vcvtps2ph256(__vector(8) float, int)’ return (__m128i) __builtin_ia32_vcvtps2ph256 ((__v8sf) __A, __I); 

由於唯一的變化來自其成功的項目生成和上述被取消註釋以下任一種或兩種:

#include <magick/api.h> 
#include <magick/magick.h> 

我很確定我的構建設置有問題。我沒有找到關於GraphicsMagick在編譯器/鏈接器選項上的特殊限制的文檔。發現這可能很好地解決了這個問題。

回答

0

從項目範圍內的CXXFLAGS中使用std=c++0x改爲std=gnu++11似乎已解決該問題。無論出於何種原因,似乎graphicsmagick 1.3.18-3是而不是可用於從c/C++ APIs std=c++0x。我知道這不是一個完整的解釋或答案,但它使事情建立。

1

使用<magick/api.h>標題;這確保類型和前向聲明以正確的順序出現。

+0

完全適用於這兩種測試。真正的項目吐出了數千行錯誤,如:「/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/include/f16cintrin.h:In function'__m128i _mm256_cvtps_ph(__ m256,int)': /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/include/f16cintrin.h:73:66:錯誤:無法將'__m256 {aka float}'轉換爲'__vector(8)float'作爲參數'1' 到 '__vector(8)短整型__builtin_ia32_vcvtps2ph256(__載體(8)浮子,INT)' 回報(__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)__A,__I); 「 – justinzane

+0

任何幫助與現有的項目和依賴性整合GraphicsMagick工具? – justinzane

0

這已在GraphicsMagick 1.3.20中修復。

我發現這個in the ChangeLog

2014-06-15 Bob Friesenhahn

wand/magick_compat.h: Use MAGICK_ATTRIBUTE definition from magick/common.h. magick/common.h (MAGICK_ATTRIBUTE): Don't undefine __attribute__ since this may be used >by system or compiler headers. Define private macro instead. Resolves SourceForge bug #270 "Compile error with g++ -std=c++11".

RHEL/Fedora的/ CentOS用戶,請檢查GraphicsMagick工具更新請求EPEL7在紅帽Bugzilla的,Bug ID 1131926