您的位置:首页 > Web前端 > JavaScript

Json-c在s3c6410上的移植

2014-10-07 15:34 239 查看
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
把这两个注释, 编译顺利通过。


成功。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: