-1

On Macbook, I am making something with 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.`>

when I try to compile it,

it prints out error, but I have json.h file in include file.

> 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 is definitely exists

roulibic
  • 325
  • 3
  • 9
yolohoam
  • 31
  • 2
  • 6

1 Answers1

7

It's likely that the compiler doesn't have the json-c subdirectory in its include path.

With luck, you can just add that to your inclusion:

#include "json-c/json.h"

This only works if that header is stand-alone, i.e. it doesn't reference any further headers in json-c/.

If that fails you have to tell the compiler when you invoke it:

$ gcc -I/usr/local/include/json-c/ a.c
unwind
  • 391,730
  • 64
  • 469
  • 606