I'm trying to use GraphicsMagick and got odd build errors, so I added #include <magick/magick.h>
to
#include <stdio.h>
int main(int argc, char *argv[]){
printf("hello magick");
return 0;
}
just to see WTF was going on. Obviously hello_world compiles fine. Simply adding the magick header causes tons of errors compiling with any of the following:
-o test.o $(pkg-config --cflags --libs GraphicsMagick) test.c
-o test.o $(GraphicsMagick-config --cflags --libs) test.c
From clang:
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 *);
The solution suggested by Mr. Hale (#1) works perfectly for the test. Trying in the real project; gcc spits thousands of line of errors like:
/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);
Since the only change from having the project build successfully and the above was uncommenting either one or both of the following:
#include <magick/api.h>
#include <magick/magick.h>
I'm quite sure I've got something wrong with the build settings. I'm not having success finding documentation on what particular restrictions GraphicsMagick places on compiler/linker options. Finding that might well solve the problem.
Changing from using std=c++0x
to std=gnu++11
in the project-wide CXXFLAGS seems to have resolved the issue. For whatever reason, it seems that graphicsmagick 1.3.18-3 is not usable from the c/c++ APIs with std=c++0x
. I know this is not a complete explanation or answer, but it makes things build.