用apt-get安裝emacs的話,版本是23.1.1,版本太低,所以在GNU的網站下了一個GNU emacs來安裝。
將在GNU的ftp下載的檔案包解壓到一目錄,cd進入該目錄,然後 ./configure進行配置產生make檔案,但是運行完一陣子後報錯如下
You seem to be running X, but no X development libraries<br />were found. You should install the relevant development files for X<br />and for the toolkit you want, such as Gtk+, Lesstif or Motif. Also make<br />sure you have development files for image handling, i.e.<br />tiff, gif, jpeg, png and xpm.<br />If you are sure you want Emacs compiled without X window support, pass<br />--without-x<br />to configure.<br />
原來是沒有安裝GTK的開發庫,可以安裝最新的gtk-3也可以安裝gtk-2.0
sudo apt-get install libgtk2.0-dev
或者選擇用系統裡的Synaptic管理器進行安裝
再運行./configure
,沒想到又報錯了,如下:
configure: error: The following required libraries were not found:<br /> libXpm libjpeg libgif/libungif libtiff<br />Maybe some development libraries/packages are missing?<br />If you don't want to link with them give<br /> --with-xpm=no --with-jpeg=no --with-gif=no --with-tiff=no<br />as options to configure
貌似是缺幾個庫:
libXpm libjpeg libgif/libungif libtiff
再進行安裝
sudo apt-get install libxpm-dev<br />sudo apt-get install libjpeg62-dev<br />sudo apt-get install libgif-dev<br />sudo apt-get install libtiff4-dev
然後再運行./configure
,這下終於可以正常地跑到結束了,看輸出的資訊,該產生的檔案都產生了。於是,運行make
,再運行sudo make install
,經過一段時間後,編譯結束,安裝成功。
如果遇到編譯錯誤。並且開啟emacs後報錯為“Cannot open termcap database file”,
少了個叫libncurses5-dev庫,於是,運行:
sudo apt-get install libncurses5-dev
因為前面編譯過,所以運行make clean,make distclean來清理一下,
再重新運行./configure,make,sudo make install,這回就完整安裝成功了
如果報錯為:
/usr/bin/ld: cannot find -linux-gnu<br />collect2: ld returned 1 exit status<br />make[1]: *** [temacs] Error 1<br />make[1]: Leaving directory `/home/gexueyuan/emacs-23.3/src'<br />make: *** [src] Error 2
那麼是因為在11.04中你安裝了gtk3.0,而gtk2.0沒有安裝,這時只要
sudo apt-get install libgtk2.0-dev
然後再進行
再重新運行./configure,make ,錯誤會變成
/usr/include/glib-2.0/glib/gtypes.h:34:24: fatal error: glibconfig.h: No such file or directory
不要緊,這時因為11.04版本的問題,emace的網站給出瞭解決方法
http://lists.gnu.org/archive/html/bug-gnu-emacs/2011-04/msg00307.html
具體就是在configure.in和configure中修改
cpp_undefs="`echo $srcdir $configuration $canonical unix |
這一行,結尾添加i386
cpp_undefs="`echo $srcdir $configuration $canonical unix i386 |
然後再重新編譯,大功告成,在終端輸入emacs進入emacs介面。
另附一個我在10.10下編譯出錯的問題
出錯資訊:
Loading international/mule-cmds...
Cannot open load file: case-table
make[1]: *** [bootstrap-emacs] 錯誤 255
make[1]:正在離開目錄 `/home/zerdison/下載/emacs-23.2/emacs-23.2/src'
make: *** [src] 錯誤 2
還以為是下載的原始碼出錯,又下了一次問題依舊,改編譯參數等也沒用。
把路徑改成英文後
make install
大功告成。