Putty是一款非常好用的開源的終端軟體。支援大多數遠程登入協議。
不過在solaris下面除了terminal好像還沒有類似SecureCRT和putty這樣的終端軟體。
Putty是開源的,代碼可以在 http://www.putty.nl/download.html 下載到。
下面主要介紹編譯putty的辦法:
首先進入下載到putty0.6,進入到unix目錄,運行./configure
這樣會根據機器的情況自動產生Makefile。
然後make就可以了。
在make的過程中會出現一些問題,現總結如下:
1、符號串連錯誤
Undefined first referenced
symbol in file
in6addr_loopback uxnet.o
in6addr_any uxnet.o
ld: fatal: Symbol referencing errors. No output written to plink
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `plink'
原因:編譯時間沒有找到ipv6的庫。
解決辦法:修改Makefile
在ULDFLAGS = -lxnet 後面加上 -lsocket 就可以了。
2、編譯選項報錯
gcc -o puttygen cmdgen.o import.o misc.o notiming.o sshaes.o sshbn.o /
sshdes.o sshdss.o sshdssg.o sshmd5.o sshprime.o sshpubk.o /
sshrand.o sshrsa.o sshrsag.o sshsh512.o sshsha.o time.o /
tree234.o uxcons.o uxgen.o uxmisc.o uxnoise.o uxstore.o /
version.o -lxnet
gcc -g -O2 -Wall -Werror -DHAVE_CONFIG_H -I/usr/local/include/gtk-1.2 -I/usr/local/include/glib-1.2 -I/usr/local/lib/glib/include -I/usr/openwin/include -I.././ -I../charset/ -I../windows/ -I../unix/ -I../mac/ -I../macosx/ -c ../config.c
../config.c: In function `portfwd_handler':
../config.c:1060: warning: unused variable `idx'
*** Error code 1
make: Fatal error: Command failed for target `config.o'
原因:有些標頭檔包含#pragma ident string 指示,其功能是把string加入.comment部分,有沒有對程式執行沒有影響,但是gcc無法識別,會產生警告,由於沒有許可權修改標頭檔,將 makefile中的編譯選項 -Werror去掉,該編譯選項令編譯器將警告當作錯誤處理,去掉後產生警告make也不會停止。
解決辦法:去掉makefile裡的-Werror選項。
3、系統調用
gcc -g -O2 -Wall -DHAVE_CONFIG_H -I/usr/local/include/gtk-1.2 -I/usr/local/include/glib-1.2 -I/usr/local/lib/glib/include -I/usr/openwin/include -I.././ -I../charset/ -I../windows/ -I../unix/ -I../mac/ -I../macosx/ -c ../unix/uxpty.c
../unix/uxpty.c: In function `pty_open_master':
../unix/uxpty.c:364: error: `FIONBIO' undeclared (first use in this function)
../unix/uxpty.c:364: error: (Each undeclared identifier is reported only once
../unix/uxpty.c:364: error: for each function it appears in.)
*** Error code 1
make: Fatal error: Command failed for target `uxpty.o'
原因:uxpty.c裡使用了宏FIONBIO,這個宏實際定義在sys/filio.h中,sys/ioctl.h包含了sys/filio.h,而 uxpty.c包含了sys/ioctl.h,正常理解應該能正確引用FIONBIO,但是編譯時間確又抱錯說找不到符號FIONBIO,所以把 sys/filio.h包含進uxpty.c中再編譯就沒問題了,說明編譯器預先處理存在一定的問題。
解決辦法:把 sys/filio.h包含進uxpty.c中。
4、代碼修改
gcc -o pterm be_none.o cmdline.o config.o dialog.o fromucs.o gtkcfg.o /
gtkcols.o gtkdlg.o gtkwin.o ldisc.o ldiscucs.o localenc.o /
logging.o macenc.o mimeenc.o minibidi.o misc.o nocproxy.o /
sbcs.o sbcsdat.o sercfg.o settings.o slookup.o terminal.o /
time.o timing.o toucs.o tree234.o utf8.o uxcfg.o uxmisc.o /
uxprint.o uxpterm.o uxpty.o uxsel.o uxsignal.o uxstore.o /
uxucs.o version.o wcwidth.o xenc.o xkeysym.o xpmptcfg.o /
xpmpterm.o -lxnet -L/usr/sfw/lib -L/usr/openwin/lib -R/usr/openwin/lib -lgtk -lgdk -R/usr/sfw/lib -lgmodule -lglib -lXext -lX11 -lsocket -lnsl -lm
Undefined first referenced
symbol in file
Xutf8TextListToTextProperty gtkwin.o
Xutf8TextPropertyToTextList gtkwin.o
ld: fatal: Symbol referencing errors. No output written to pterm
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `pterm'
原因:Xutf8TextListToTextProperty和Xutf8TextPropertyToTextList兩個函數是在某版本的X11之後才有的,Xutil.h中應該有它們的原形,但在目前系統的X11版本可能沒有。
解決辦法: Xutil.h中有另外的一些函數,參數剛好吻合,XmbTextListToTextProperty和 XmbTextPropertyToTextList,所以就嘗試進行替換,編譯成功,能夠獲得可執行檔。不過最根本的解決辦法還是用新的X11去編譯。
5、運行時警告
Gtk-WARNING **: Unable to locate loadable module in module_path: "libpixmap.so"
這個問題好像非常常見。google之後找到一個在ubuntu上的解答:
This is caused by the lack of the GTK1 pixmap engine.
You can install it (and thus fix this issue) by apt-getting the __gtk-engines-pixmap__ package.
不過在blastwave上面沒有找到gtkengines。
按照以上辦法可以順利編成putty。運行./putty可以看到不錯的介面。
enjoy!
註:編譯過程由unix-center使用者he1l0編譯,本人結合自己的編譯經過總結而成。非常感謝he1l0。原帖請訪問:http://www.unix-center.net/bbs/viewthread.php?tid=1526&extra=page%3D1&page=1