LINUX编译json-c错误的解决:autoreconf找不到,json_tokener.c报错

sudo apt-get install libjson0-dev libjson0
  • 下载源码编译安装

https://github.com/jehiah/json-c

执行命令

# 依赖库, 否则可能提示autoreconf找不到
sudo apt-get install autoconf automake libtool
sudo apt-get install libffi-dev

#
sh ./autogen.sh
./configure
make
sudo make install

 这里要提一下两个编译错误:

  1. sh ./autogen.sh提示autoreconf: not found,是依赖库没有安装。执行两个install即可。

  2. 有两个类似的错误:

    json_tokener.c:201:36: error: right-hand operand of comma expression has no effect [-Werror=unused-value]
       ( ++(str), ((tok)->char_offset)++, c)
                                        ^
    json_tokener.c:467:14: note: in expansion of macro ‘ADVANCE_CHAR’
                  ADVANCE_CHAR(str, tok);

这是因为宏定义在这里展开时,多了一个返回值导致的。

解决办法:

增加宏定义:#define ADVANCE_CHAR2(str, tok)   ( ++(str), ((tok)->char_offset)++)

两个报错语句改为:ADVANCE_CHAR2(str, tok);

猜你喜欢

转载自blog.csdn.net/quantum7/article/details/82969550