I'm trying to use GraphicsMagick and got odd build errors, so I added #include <magick/magick.h>
to
我尝试使用GraphicsMagick,并且得到了奇怪的构建错误,所以我添加了#include
#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:
只是想看看WTF。显然hello_world运行良好。只需添加magick头,就会导致大量的错误编译:
- clang or gcc
-o test.o $(pkg-config --cflags --libs GraphicsMagick) test.c
- clang或gcc -o测试。o $(pkg-config—cflags—libs GraphicsMagick) test.c。
- clang or gcc
-o test.o $(GraphicsMagick-config --cflags --libs) test.c
- clang或gcc -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:
黑尔先生建议的解决方案在测试中是完美的。在真实项目中尝试;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);
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.
我很确定我的构建设置有问题。我没有成功地找到关于在编译器/链接器选项上图形化的地方有哪些特定限制的文档。发现这一点很有可能解决这个问题。
3 个解决方案
#1
1
Use the <magick/api.h>
header; this ensures types and forward declarations appear in the correct order.
使用 <魔法 api。h> 头;这将确保类型和转发声明以正确的顺序出现。
#2
0
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.
在项目范围的CXXFLAGS中,从使用std=c++0x到std=gnu++11,似乎已经解决了这个问题。无论出于什么原因,graphicsmagick 1.3.18-3似乎不能从std=c++0x的c/c++ api中使用。我知道这不是一个完整的解释或答案,但它能让事情发展。
#3
0
This has been fixed in GraphicsMagick 1.3.20.
这已经固定在GraphicsMagick 1.3.20中。
I have found this in the ChangeLog:
我在ChangeLog找到了这个:
2014-06-15 Bob Friesenhahn
2014-06-15鲍勃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".
魔杖/ magick_compat。h:用magick/common.h的MAGICK_ATTRIBUTE定义。魔法/常见。h (MAGICK_ATTRIBUTE):不要定义__attribute__,因为这可能是由系统或编译器头使用的>。定义私有宏。用g++ -std=c++11来解决SourceForge bug #270“编译错误”。
RHEL/Fedora/CentOS users, check GraphicsMagick update request for EPEL7 in RedHat Bugzilla, Bug ID 1131926
RHEL/Fedora/CentOS用户,检查GraphicsMagick更新请求在RedHat Bugzilla的EPEL7, Bug ID 1131926。
#1
1
Use the <magick/api.h>
header; this ensures types and forward declarations appear in the correct order.
使用 <魔法 api。h> 头;这将确保类型和转发声明以正确的顺序出现。
#2
0
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.
在项目范围的CXXFLAGS中,从使用std=c++0x到std=gnu++11,似乎已经解决了这个问题。无论出于什么原因,graphicsmagick 1.3.18-3似乎不能从std=c++0x的c/c++ api中使用。我知道这不是一个完整的解释或答案,但它能让事情发展。
#3
0
This has been fixed in GraphicsMagick 1.3.20.
这已经固定在GraphicsMagick 1.3.20中。
I have found this in the ChangeLog:
我在ChangeLog找到了这个:
2014-06-15 Bob Friesenhahn
2014-06-15鲍勃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".
魔杖/ magick_compat。h:用magick/common.h的MAGICK_ATTRIBUTE定义。魔法/常见。h (MAGICK_ATTRIBUTE):不要定义__attribute__,因为这可能是由系统或编译器头使用的>。定义私有宏。用g++ -std=c++11来解决SourceForge bug #270“编译错误”。
RHEL/Fedora/CentOS users, check GraphicsMagick update request for EPEL7 in RedHat Bugzilla, Bug ID 1131926
RHEL/Fedora/CentOS用户,检查GraphicsMagick更新请求在RedHat Bugzilla的EPEL7, Bug ID 1131926。