天天看點

linux gd編譯安裝失敗,Ubuntu Linux下編譯安裝gd-2.0.11出錯

Ubuntu Linux下編譯安裝gd-2.0.11出錯的解決

wget http://www.linuxidc.com/system/systemfiles/2010/5/gd-2.0.11.tar.gz

tar zxvf gd-2.0.11.tar.gz

cd gd-2.0.11

sudo ./configure --prefix=/usr/local/gd2

sudo make

make時出錯了:

cc -DHAVE_CONFIG_H -I. -I. -I. -I/usr/local/include/freetype2 -I/usr/local/include -I/usr/local/include/libpng12 -g -O2 -MT gdft.lo -MD -MP -MF  .deps/gdft.Tpo -c gdft.c  -fPIC -DPIC -o .libs/gdft.lo

In file included from gdft.c:56:

/usr/local/include/freetype2/freetype/freetype.h:20:2: error: #error "`ft2build.h' hasn't been included yet!"

/usr/local/include/freetype2/freetype/freetype.h:21:2: error: #error "Please always use macros to include FreeType header files."

/usr/local/include/freetype2/freetype/freetype.h:22:2: error: #error "Example:"

/usr/local/include/freetype2/freetype/freetype.h:23:2: error: #error "  #include "

/usr/local/include/freetype2/freetype/freetype.h:24:2: error: #error "  #include FT_FREETYPE_H"

make[2]: *** [gdft.lo] Error 1

make[2]: Leaving directory `/home/soft/gd-2.0.11'

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/home/soft/gd-2.0.11'

make: *** [all] Error 2

在網上搜尋了一下,沒有解決辦法,有人說是注釋掉 /usr/local/include/freetype2/freetype/freetype.h 檔案中那幾行預處理指令,我覺得那樣不妥,經過我的分析,應該是gdft.c使用了freetype庫,但是忘記包含其中一個必需包含的頭檔案 ft2build.h了,于是就報錯了。

我的做法是:

vim gdft.c

增加:

#ifndef FT_FREETYPE_H

#include

#endif

linux gd編譯安裝失敗,Ubuntu Linux下編譯安裝gd-2.0.11出錯

這樣以後,再make ,然後make install ,再也沒有報錯了。  這裡證明我的判斷是正确的,這很可能是程式的一個bug。

linux gd編譯安裝失敗,Ubuntu Linux下編譯安裝gd-2.0.11出錯