ubuntu下交叉编译imagemagick

环境:ubuntu16.04

交叉编译器版本号:4.8.3

在编译之前要编译以下其依赖的软件或库:freetype,libpng,libxml2,libtiff,libjpeg,zlib,graphviz

zlib库

1.tar xvf zlib-1.2.11.tar.xz

2.export CC=arm-linux-gnueabi-gcc

3.export AR=arm-linux-gnueabi-ar

4.mkdir build

5.cd build

6.   ../configure --prefix=$PWD/_install

7.make

8.make install

libtiff没有依赖,使用autoconf生成configure脚本,那么直接编译libtiff

1.wget http://download.osgeo.org/libtiff/tiff-4.0.8.tar.gz

2.tar -xvf tiff-4.0.8.tar.gz

3.cd tiff-4.0.8

4.autoconf

5.export CC=arm-linux-gnueabi-gcc

6.export AR=arm-linux-gnueabi-ar

7.mkdir compile

8.cd compile

9.   ../configure --prefix=$PWD/_install --host=arm-linux-gnueabi

10.make

11.make install

libjpeg没有依赖,使用autoconf生成configure脚本

1.wget www.ijg.org/files/jpegsrc.v9b.tar.gz

2.tar xvf jpegsrc.v9b.tar.gz

3.cd jpeg-9b/
4.autoconf
5.mkdir build

6.   ../configure --prefix=$PWD/_install --host=arm-linux-gnueabi

7.make

8.make install

libpng依赖于zlib,使用autoconf生成configure脚本

1.wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.32.tar.xz

2.tar xvf libpng-1.6.32.tar.xz

3.cd libpng-1.6.32

4.mkdir build

5.cd build

6.   ../configure --prefix=$PWD/_install  LIBS=-L/home/jello/zlib-1.2.11/build/_install/lib CPPFLAGS=-I/home/jello/zlib-1.2.11/build/_install/include --host=arm-linux-gnueabi

7.make

8.make install

libxml2依赖于zlib,configure由autoconf生成,配置项--without-python

1.axel ftp://xmlsoft.org/libxml2/libxml2-2.9.4.tar.gz

2.tar xvf libxml2-2.9.4.tar.gz

3.cd libxml2-2.9.4

4.mkdir build

5.cd build

6. ../configure --prefix=$PWD/_install LIBS=-L/home/jello/zlib-1.2.11/build/_install/lib CPPFLAGS=-I/home/jello/zlib-1.2.11/build/_install/include --host=arm-linux-gnueabi --without-python
7.make
8.make install

freetype依赖于zlib,libpng

1.wget nongnu.askapache.com/freetype/freetype-2.6.5.tar.gz

2.tar xvf freetype-2.6.5.tar.gz

3.cd freetype-2.6.5

4.mkdir build

5.cd build

6. export LDFLAGS="-L/home/jello/zlib-1.2.11/build/_install/lib -L/home/jello1/libpng-1.6.32/build/_install/lib"

7.export CFLAGS="-I/home/jello/zlib-1.2.11/build/_install/include -I/home/jello/libpng-1.6.32/build/_install/include"
8.最重要的一步:还记得刚安装好的libpng库吗?现在需要它的帮助,进入它的安装目录吧,笔者的在/home/jello/libpng-1.6.32/build/__install下,所以进入其lib目录:
cd /home/jello/libpng-1.6.32/build/__install/lib

接着再创建一个软链接,链接到库libpng16.so.16.32.0

ln -s libpng12.so libpng16.so.16.32.0

好了这一步很关键,如果不做这一步,会提示找不到-lpng12,也就是找不到库文件libpng12.so那么回到之前的build目录吧

9. ../configure --prefix=$PWD/__install --host=arm-linux-gnueabi

10.make

11.make install

graphviz 不需要编译此软件,只需要交叉编译其中的3个库即可,libcdt.so libcgraph.so libgvc.so,编译imagemagick需要这三个库及及其头文件路径

1.wget http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.40.1.tar.gz

2. tar xvf graphviz-2.40.1.tar.gz

3. cd graphviz-2.40.1

4.mkdir build

5.cd build

6.export CC=arm-linux-gnueabi-gcc

7.export AR=arm-linux-gnueabi-ar

8.  ../configure --prefix=$PWD/__install --host=arm-linux-gnueabi

9.make (会有错误信息,不用管,因为在这个过程中会运行编译好的arm程序,但当前是pc机,因此不能运行,故报错)

10.make install (会有错误信息,不用管,我们只需要生成的那三个库和头文件就可以了)

 

准备已经妥当,开始交叉编译imagemagick

1.获取源码:

git clone https://github.com/ImageMagick/ImageMagick.git

2.指定库和头文件的路径,这里就是为了保证在交叉编译时找到正确的库!

export CFLAGS="-I/home/jello/freetype-2.6.5/build/_install/include -I/home/jello/freetype-2.6.5/build/_install/include/freetype2 -I/home/jello/libpng-1.6.32/build/_install/include -I/home/jello/tiff-4.0.8/compile/_install/include -I/home/jello/jpeg-9b/build/_install/include -I/home/jello/libxml2-2.9.4/build/_install/include -I/home/jello/libxml2-2.9.4/build/_install/include/libxml2 -I/home/jello/zlib-1.2.11/build/_install/include -I/home/jello/graphviz-2.40.1/build/_install/include/graphviz"

export LDFLAGS="-L/home/jello/freetype-2.6.5/build/_install/lib -L/home/jello/libpng-1.6.32/build/_install/lib -L/home/jello/tiff-4.0.8/compile/_install/lib -L/home/jello/jpeg-9b/build/_install/lib -L/home/jello/libxml2-2.9.4/build/_install/lib -L/home/jello/zlib-1.2.11/build/_install/lib -L/home/jello/graphviz-2.40.1/build/_install/lib"

3.cd ImageMagick

4.mkdir build

5.cd build

6. ../configure --prefix=$PWD/__install --disable-installed --without-perl --without-x --without-fpx --without-wmf --disable-openmp --host=arm-hisiv400-linux-gnueabi

7.在当前目录项会生成Makefile文件,修改其中的CFLAGS,笔者生成的Makefile文件中的CFLAGS如下:

CFLAGS = -I/usr/include/libxml2 -I/usr/include/libpng12 -I/usr/include/graphviz -I/usr/include/freetype2   -I/home/jello/freetype-2.6.5/build/_install/include -I/home/jello/freetype-2.6.5/build/_install/include/freetype2 -I/home/jello/libpng-1.6.32/build/_install/include -I/home/jello/tiff-4.0.8/compile/_install/include -I/home/jello/jpeg-9b/build/_install/include -I/home/jello/libxml2-2.9.4/build/_install/include -I/home/jello/libxml2-2.9.4/build/_install/include/libxml2 -I/home/jello/zlib-1.2.11/build/_install/include -I/home/jello/graphviz-2.40.1/build/_install/include/graphviz -Wall -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16

将其中含有/usr/include的路径删掉,笔者删除后如下:

CFLAGS = -I/usr/include/graphviz -I/usr/include/freetype2   -I/home/jello/freetype-2.6.5/build/_install/include -I/home/jello/freetype-2.6.5/build/_install/include/freetype2 -I/home/jello/libpng-1.6.32/build/_install/include -I/home/jello/tiff-4.0.8/compile/_install/include -I/home/jello/jpeg-9b/build/_install/include -I/home/jello/libxml2-2.9.4/build/_install/include -I/home/jello/libxml2-2.9.4/build/_install/include/libxml2 -I/home/jello/zlib-1.2.11/build/_install/include -I/home/jello/graphviz-2.40.1/build/_install/include/graphviz -Wall -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16

 8.make

9.make install

ok完结

 

posted @ 2017-09-03 23:19  Jello  阅读(1832)  评论(0编辑  收藏  举报