我試圖使用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在編譯器/鏈接器選項上的特殊限制的文檔。發現這可能很好地解決了這個問題。
完全適用於這兩種測試。真正的項目吐出了數千行錯誤,如:「/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
任何幫助與現有的項目和依賴性整合GraphicsMagick工具? – justinzane