在 Macbook 上,我正在使用 json-c( https://github.com/json-c/json-c ) 制作一些东西
gcc a.c
a.c:1:10: fatal error: 'json.h' file not found
#include "json.h"
^
1 error generated.`>
当我尝试编译它时,
它打印出错误,但包含文件中有 json.h
文件。
> cd /usr/local/include/json-c/
> ls
arraylist.h json_config.h json_tokener.h
bits.h json_inttypes.h json_util.h
debug.h json_object.h linkhash.h
json.h json_object_iterator.h printbuf.h
json_c_version.h json_object_private.h random_seed.h
/usr/include/json-c/json.h 肯定存在
最佳答案
编译器的包含路径中可能没有 json-c
子目录。
如果幸运的话,您可以将其添加到您的包含内容中:
#include "json-c/json.h"
这仅在该 header 是独立的情况下才有效,即它不引用 json-c/
中的任何其他 header 。
如果失败,您必须在调用它时告诉编译器:
$ gcc -I/usr/local/include/json-c/ a.c
关于c - gcc不包含c头文件json-c,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37654661/