一些库在各个项目经常重用.如jpeg,freetype,iconv 等.每次大型项目均会反复重用.因此按照原来项目规范,一般都放在项目libs目录下,但后来发现,每个项目都做重复操作.也完全没有必要.因为现在是将其归纲到一个comm_lib公用信息.
以下是常用库的ARM-Linux移植,我是放在/home/hxy/common_lib 目录下.按到移植规范,输出在 output/arm-linux下,库本身在 libs 下面.
以下是常见库的移植.在这里留作教学和备份用.
通用类
1.zlib库移植
- 下载
- 解压 tar xvzf zlib-1.2.3.tar.gz
- cd zlib-1.2.3
- 生成Makefile(注意zlib只能静态,动态分开编译,因此要生成两次Makefile和两次编译和安装)
- 生成静态库 CC=arm-linux-gcc CPP="arm-linux-gcc -E" AR="arm-linux-ar rc" RANLIB=arm-linux-ranlib ./configure --prefix=$PWD/../../output/arm-linux
- 生成动态库 CC=arm-linux-gcc CPP="arm-linux-gcc -E" AR="arm-linux-ar rc" RANLIB=arm-linux-ranlib ./configure --shared --prefix=$PWD/../../output/arm-linux
- 编译 make
- 安装 make install
图像类
1.jpeg库,用于jpeg图像处理
- 解压 tar xvzf jpegsrc.v6b.tar.gz
- cd jpeg-6b
- 生成Makefile
- CC=arm-linux-gcc CPP="arm-linux-gcc -E" AR="arm-linux-ar" RANLIB="arm-linux-ranlib" STRIP="arm-linux-strip" ./configure --host=arm-linux --prefix=$PWD/../../output/arm-linux --enable-shared --enable-static
- 上述方法只会成功一次。因此正确的方法
- ./configure --host=arm-linux --prefix=$PWD/../../output/arm-linux --enable-shared --enable-static
- 然后在生成Makefile 里把CC,AR,AR2,STRIP改成arm-linux-gcc版本
- 编译 make
- mkdir -p $PWD/../../output/arm-linux/man/man1
- 安装 make install
- 注意这个库的安装程序有BUG,不会自动创建发布的lib,include,man等,因此要手工创建,要不先把其它库做好,再安装这个库
- mkdir -p /home/hxy/common_lib/output/arm-linux/include
- mkdir -p /home/hxy/common_lib/output/arm-linux/lib
- mkdir -p /home/hxy/common_lib/output/arm-linux/man/man1
-
2.png 用于PNG图像显示
- 解压 tar xvjf libpng-1.2.19.tar.bz2
- cd libpng-1.2.19
- 生成Makefile
- ./configure --host=arm-linux --enable-shared --enable-static --prefix=$PWD/../../output/arm-linux
-
- 编译 make
- 安装 make install
3.tiff库 ,(tiff格式显示)
- 解压 tar xvzf tiff-3.8.2.tar.gz
- cd tiff-3.8.2
- 生成makefile
- ./configure --host=arm-linux --enable-shared --enable-static --enable-jpeg --enable-zlib --prefix=$PWD/../../output/arm-linux
- 编译 make
- 安装 make install
音频类
2.mad
- 解压 tar xvzf libmad-0.15.1b.tar.gz
- cd libmad-0.15.1b
- 生成Makefile(标准)
- ./configure --host=arm-linux --enable-shared --enable-static --prefix=$PWD/../../output/arm-linux
-
- 去掉Makefile中-fforce-mem
- 因为arm-linux-gcc不认识这个选项,编译提示 error: unrecognized command line option "-fforce-mem"
-
- 编译make
- 安装 make install
3.id3tag:读取mp3信息
官网 http://www.underbit.com/products/mad/
- ./configure --host=arm-linux --enable-shared --enable-static --prefix=$PWD/../../output/arm-linux
- 编译 make
- 安装 make install
4.ogg 一种音频解码格式
-
- 解压 tar xvzf libogg-1.1.4.tar.gz
- cd libogg-1.1.4
- 生成Makefile (标准)
- ./configure --host=arm-linux --enable-shared --enable-static --prefix=$PWD/../../output/arm-linux
-
- 编译make
- 安装 make install
5.flac 移植
- 解压 tar xvf flac-1.2.1.tar.gz
- cd flac-1.2.1
- 生成Makefile (标准)
- ./configure --host=arm-linux --enable-shared --enable-static --prefix=$PWD/../../output/arm-linux修改源码 examples/cpp/encode/file/main.cpp,增加 #include <string.h>
- 编译make
- 安装 make install
文字编码类
1.iconv库 用于文字编码转换
- 下载:http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
- 解压 tar xvzf libiconv-1.13.1.tar.gz
- cd libiconv-1.13.1
- 生成Makefile (标准)
- ./configure --host=arm-linux --enable-shared --enable-static --prefix=$PWD/../../output/arm-linux
-
- 编译make
- 安装 make install
2. freetype:开源高质理字体显示函数库
- 主页:http://www.freetype.org/
- 下载:http://ftp.twaren.net/Unix/NonGNU/freetype/freetype-2.3.11.tar.gz
- 解压 tar xvzf freetype-2.3.11.tar.gz
- cd freetype-2.3.11
- 生成Makefile (标准)
- ./configure --host=arm-linux --enable-shared --enable-static --prefix=$PWD/../../output/arm-linux
-
- 编译make
- 安装 make install
3.