linux json arm,json-c-0.8移植到ARM平台

环境:fedora

源码:json-c-0.8.tar.gz

交叉编译环境:arm-unknown-linux-gnu-gcc(您的交叉编译工具)

[root@mfr json-c-0.8]#tar –xzvf json-c-0.8.tar.gz

[root@mfr json-c-0.8]#cd json-c-0.8

[root@mfr json-c-0.8]#./configure CC= arm-unknown-linux-gnu-gcc –host=arm-unknown-linux –build=i686-pc-linux

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for a thread-safe mkdir -p... /bin/mkdir -p

checking for gawk... gawk

checking whether make sets $(MAKE)... yes

checking for arm-unknown-linux-strip... no     ---------应该是 arm-unknown-linux-gnu-strip

checking for strip... strip

configure: WARNING: In the future, Autoconf will not detect cross-tools

whose name does not start with the host triplet.  If you think this

configuration is useful to you, please write to autoconf@gnu.org.

checking for style of include used by make... GNU

checking for arm-unknown-linux-gcc... arm-unknown-linux-gnu-gcc

checking for C compiler default output file name... a.out

checking whether the C compiler works... yes

checking whether we are cross compiling... yes

checking for suffix of executables...

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether arm-unknown-linux-gnu-gcc accepts -g... yes

checking for arm-unknown-linux-gnu-gcc option to accept ISO C89... none needed

checking dependency style of arm-unknown-linux-gnu-gcc... gcc3

checking how to run the C preprocessor... arm-unknown-linux-gnu-gcc -E

checking for grep that handles long lines and -e... /bin/grep

checking for egrep... /bin/grep -E

checking for ANSI C header files... yes

checking for sys/types.h... yes

checking for sys/stat.h... yes

checking for stdlib.h... yes

checking for string.h... yes

checking for memory.h... yes

checking for strings.h... yes

checking for inttypes.h... yes

checking for stdint.h... yes

checking for unistd.h... yes

checking fcntl.h usability... yes

checking fcntl.h presence... yes

checking for fcntl.h... yes

checking limits.h usability... yes

checking limits.h presence... yes

checking for limits.h... yes

checking for strings.h... (cached) yes

checking syslog.h usability... yes

checking syslog.h presence... yes

checking for syslog.h... yes

checking for unistd.h... (cached) yes

checking sys/param.h usability... yes

checking sys/param.h presence... yes

checking for sys/param.h... yes

checking stdarg.h usability... yes

checking stdarg.h presence... yes

checking for stdarg.h... yes

checking for an ANSI C-conforming const... yes

checking for size_t... yes

checking for vprintf... yes

checking for _doprnt... no

checking for working memcmp... no

checking for stdlib.h... (cached) yes

checking for GNU libc compatible malloc... no

checking for stdlib.h... (cached) yes

checking for GNU libc compatible realloc... no

checking for strndup... yes

checking for strerror... yes

checking for vsnprintf... yes

checking for vasprintf... yes

checking for open... yes

checking for vsyslog... yes

checking for strncasecmp... yes

checking build system type... i686-pc-linux-gnu

checking host system type... arm-unknown-linux-gnu

checking for a sed that does not truncate output... ./configure: line 5419: echo: write error: Broken pipe

/bin/sed

checking for fgrep... /bin/grep -F

checking for ld used by arm-unknown-linux-gnu-gcc... /usr/local/arm/arm-unknown-linux-gnu/arm-unknown-linux-gnu/bin/ld

checking if the linker (/usr/local/arm/arm-unknown-linux-gnu/arm-unknown-linux-gnu/bin/ld) is GNU ld... yes

checking for BSD- or MS-compatible name lister (nm)... no

checking for arm-unknown-linux-dumpbin... no           ---没有此命令

checking for arm-unknown-linux-link... no        ---没有此命令

checking for dumpbin... no

checking for link... link -dump -symbols

checking the name lister (link -dump -symbols) interface... BSD nm

checking whether ln -s works... yes

checking the maximum length of command line arguments... 1966080

checking whether the shell understands some XSI constructs... yes

checking whether the shell understands " ="... yes

checking for /usr/local/arm/arm-unknown-linux-gnu/arm-unknown-linux-gnu/bin/ld option to reload object files... -r

checking how to recognize dependent libraries... pass_all

checking for arm-unknown-linux-ar... no   ---应该是arm-unknown-linux-gnu-ar

checking for ar... ar

checking for arm-unknown-linux-strip... strip ---应该是arm-unknown-linux-gnu-strip

checking for arm-unknown-linux-ranlib... no  ---应该是arm-unknown-linux-gnu-ranlib

checking for ranlib... ranlib

checking command to parse link -dump -symbols output from arm-unknown-linux-gnu-gcc object... failed

checking for dlfcn.h... yes

checking for objdir... .libs

checking if arm-unknown-linux-gnu-gcc supports -fno-rtti -fno-exceptions... no

checking for arm-unknown-linux-gnu-gcc option to produce PIC... -fPIC -DPIC

checking if arm-unknown-linux-gnu-gcc PIC flag -fPIC -DPIC works... yes

checking if arm-unknown-linux-gnu-gcc static flag -static works... yes

checking if arm-unknown-linux-gnu-gcc supports -c -o file.o... yes

checking if arm-unknown-linux-gnu-gcc supports -c -o file.o... (cached) yes

checking whether the arm-unknown-linux-gnu-gcc linker (/usr/local/arm/arm-unknown-linux-gnu/arm-unknown-linux-gnu/bin/ld) supports shared libraries... yes

checking whether -lc should be explicitly linked in... no

checking dynamic linker characteristics... GNU/Linux ld.so

checking how to hardcode library paths into programs... immediate

checking whether stripping libraries is possible... yes

checking if libtool supports shared libraries... yes

checking whether to build shared libraries... yes

checking whether to build static libraries... yes

configure: creating ./config.status

config.status: creating Makefile

config.status: creating json.pc

config.status: creating config.h

config.status: executing depfiles commands

config.status: executing libtool commands

[root@mfr json-c-0.8]# make

显示内容略

[root@mfr json-c-0.8]# make install

显示内容略

至此交叉编译完毕

json头文件将被安装在/usr/local/include/json目录

交叉编译后的动态库文件被安装在/usr/local/lib目录

编译json源码中自带的例子

[root@mfr json-c-0.8]##arm-unknown-linux-gnu-gcc –ljson –I/usr/local/include/json/ -L/usr/local/lib –o test2 test2.c –std=c99

出现undefined reference to “rpl_malloc”和undefined reference to “rpl_realloc”两处未定义错误,费了半天劲终于发现需要手动修改Makefile和config.h.in才能解决上面问题。

手动修改Makefile

1、STRIP=arm-unknown-linux-gnu-strip

2、AR= arm-unknown-linux-gnu-ar

3、RANLIB= arm-unknown-linux-gnu-ranlib

手动修改config.h.in

屏蔽掉

#undef malloc

#undef realloc

修改完上面两个文件,重新执行make和make install

编译json源码中自带的例子,交叉编译时一定要指定 -std=c99,为什么自己百度。。。

[root@mfr json-c-0.8]##arm-unknown-linux-gnu-gcc –ljson –I/usr/local/include/json/ -L/usr/local/lib –o test2 test2.c –std=c99

编译通过,此时在当前目录生成test2可执行文件

将/usr/local/lib目录下得libjson.*和pkgconfig目录都拷贝到ARM设备上得文件系统的/lib目录,

将test2拷贝到ARM设备上文件系统的/tmp目录,执行test2可得到正确结果。。。。。

至此json-c-0.8移植成功移植到arm系统,以后可以使用c语言编写的cgi返回JSON格式数据到客户端浏览器,浏览器使用javascript解析JSON数据,这样客户端浏览器和服务器端的数据传递方式清楚了。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值