首頁 > 軟體

Ubuntu 16.04下交叉編譯ImageMagick

2020-06-16 17:08:38

環境:Ubuntu 16.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完結

相關閱讀

利用ImageMagick繪製三基色原理圖 http://www.linuxidc.com/Linux/2012-09/70007.htm

Linux下PHP支援ImageMagick和MagicWandForPHP http://www.linuxidc.com/Linux/2011-01/31539.htm

Linux下用ImageMagick玩影象魔術 http://www.linuxidc.com/Linux/2010-06/26921.htm

Linux下ImageMagick和MagicWand For PHP的安裝 http://www.linuxidc.com/Linux/2008-07/14525.htm

Linux下ImageMagick和JMagick的安裝整理 http://www.linuxidc.com/Linux/2008-09/15649.htm

Linux系統上編譯好的ImageMagick遷移到另一台機器 http://www.linuxidc.com/Linux/2017-03/141420.htm


IT145.com E-mail:sddin#qq.com