交叉编译libbz2,zlib

在linux平台,使用arm交叉编译链编译libbz2,zlib

起因,在arm平台下使用boost库.
修改Makefile文件
SHELL=/bin/bash

# To assist in cross-compiling
CC=/home/frp/code/third_libs/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
AR=/home/frp/code/third_libs/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar
RANLIB=/home/frp/code/third_libs/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ranlib
LDFLAGS=

BIGFILES=-D_FILE_OFFSET_BITS=64
CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)

# Where you want it installed when you do 'make install'
PREFIX=/home/frp/code/third_libs/bzip2-1.0.6/install


OBJS= blocksort.o  \
      huffman.o    \
      crctable.o   \
      randtable.o  \
      compress.o   \
      decompress.o \
      bzlib.o

all: libbz2.a bzip2 bzip2recover

bzip2: libbz2.a bzip2.o
	$(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2

bzip2recover: bzip2recover.o
	$(CC) $(CFLAGS) $(LDFLAGS) -o bzip2recover bzip2recover.o

使用bzip2-1.0.6版本,上面的代码为Makefile文件中的部分(修改后的).

  • 修改了SHELL=后的sh为bash,不修改的话会报如下错误:

Doing 6 tests (3 compress, 3 uncompress) …
If there’s a problem, things might stop at this point.
./bzip2 -1 < sample1.ref > sample1.rb2
./bzip2: 1: ./bzip2: Syntax error: word unexpected (expecting “)”)
Makefile:57: recipe for target ‘test’ failed
make: *** [test] Error 2

  • 修改CC=,AR=,RANLIB=为实际的交叉编译链中gcc,ar,ranlib的路径
  • 修改PREFIX=为要安装位置,如果默认的话可能会覆盖系统的这些库(没试过)
  • 去掉all后面的test,测试老是不通过,猜想可能是于实际平台不符导致的
编译
make
make install

ZLIB

进入zlib源码所在文件夹

export CC=/home/frp/code/third_libs/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
mkdir install
./configure --prefix=$PWD/install
make && make install
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值