Json-c在s3c6410上的移植

Json-c在ubuntu13.04上的安装使用

步骤:

1、  Json包:json-c-0.7.tar.gz
环境:ubuntu 13.04

Gcc : 4.2

解压缩等省略……

2、  常规3步:

./configure

Make

Make install

3、  测试

进入解压后的json-c目录,找到test1.c测试文件。

编译:gcc test1.c –ojson_test1 -std=c99 -I/usr/include/json -L/usr/lib/i386-linux-gnu/ -ljson

执行:./json_test1

结果:

my_string=          

my_string.to_string()="\t"

my_string=\

my_string.to_string()="\\"

my_string=foo

my_string.to_string()="foo"

my_int=9

my_int.to_string()=9

my_array=

      [0]=1

      [1]=2

      [2]=3

      [3]=null

      [4]=5

my_array.to_string()=[ 1, 2, 3, null, 5 ]

my_object=

      abc:12

      foo:"bar"

      bool0:false

      bool1:true

      arr:[ 1, 2, 3, null, 5 ]

my_object.to_string()={ "abc": 12,"foo": "bar", "bool0": false, "bool1":true, "arr": [ 1, 2, 3, null, 5 ] }

new_obj.to_string()="\u0003"

new_obj.to_string()="foo"

new_obj.to_string()="foo"

new_obj.to_string()="ABC"

new_obj.to_string()=null

new_obj.to_string()=true

new_obj.to_string()=12

new_obj.to_string()=12.300000

new_obj.to_string()=[ "\n" ]

new_obj.to_string()=[ "\nabc\n" ]

new_obj.to_string()=[ null ]

new_obj.to_string()=[ ]

new_obj.to_string()=[ false ]

new_obj.to_string()=[ "abc", null,"def", 12 ]

new_obj.to_string()={ }

new_obj.to_string()={ "foo":"bar" }

new_obj.to_string()={ "foo":"bar", "baz": null, "bool0": true }

new_obj.to_string()={ "foo": [null, "foo" ] }

new_obj.to_string()={ "abc": 12,"foo": "bar", "bool0": false, "bool1":true, "arr": [ 1, 2, 3, null, 5 ] }

new_obj.to_string()={"foo": { "bar": 13 } }

 

错误:-ljson参数一定放到最后。

 

Json-c在s3c6410上的移植

步骤:

1、  Json包:json-c-0.7.tar.gz
环境:ubuntu 13.04

Gcc : 4.2

         解压缩等省略……

2、   

sudo ./configure --prefix=/opt/json-c--host=arm-none-linux-gnueabi

sudo make

sudo make install

./configure CC=arm-none-linux-gnueabi-gcc --prefix=/opt/json-c --host=arm-none-linux-gnueabi

Make

Make install

3、  测试

arm-none-linux-gnueabi-gcc test1.c -o json_test1 -std=c99-I/opt/json-c/include/json -L/opt/json-c/lib  -ljson

 注:有时候交叉编译会出现 undefined reference to rpl_malloc错误

解决方案:

json-c目录下config.h.in里定义了    
#undef malloc
#undef realloc
把这两个注释, 编译顺利通过。

成功。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值