2013
Aug
31

安裝 gclient

gclient 是一個可以同時支援 SVN 與 GIT 的工具,因為編輯 V8 Engine 時,必須用到這個小工具,所以我們得先安裝它,安裝的方式如下:


安裝好後,輸入 gclient ,測試看看這個指令能不能使用。

安裝 Javascript V8 Engine

安裝 V8 需要先知道自已的 cpu 是 32 位元,還是 64 位元, 我的電腦是 32 位元,所以我指定 ia32.release , release 也可以改成 debug,如果你是使用 64 位元的系統,那麼你可以用 x64.release

  • git clone git://github.com/v8/v8.git src
  • cd src && make dependencies && make ia32.release library=shared soname_version=1.0 console=readline snapshot=off werror=no

我會用到 d8 這個 v8 command 程式,所以多加了 console=readline ,另外 v8 預設編譯的時候會自動將 warning 轉到 error ,這樣會導致一點點小小的 warning 就造成編譯失敗,加上 werror=no 就可以解決這個問題。

上兩步執行成功後,out/ia32.release/ 資料夾就會出現 libv8.so.1.0 這個重要的 v8 shared object ,接下來,就把這個檔案裝到系統 lib 資料夾下,而因為我還要開發 v8 extension ,所以還必需要將 header 檔搬到 inlcude 底下。

  • cd src && cp out/ia32.release/lib.target/libv8.so.1.0 /usr/local/lib/ && cp out/ia32.release/d8 /usr/local/bin/
  • ln -sf /usr/local/lib/libv8.so.1.0 /usr/local/lib/libv8.so
  • cd src && if [
-d /usr/local/include/v8 ]; then mkdir /usr/local/include/v8; fi;
  • cd src && cp include/*.h /usr/local/include/v8/

編譯問題處理

問題一: archives - ar 版本太舊

錯誤訊息: error: ar crT libutils.a base64.o common.o ip_addr.o radiotap.o trace.o uuid.o wpa_debug.o wpabuf.o os_unix.o eloop.o
ar: illegal option -- T

這個問題發生的原因是 /usr/bin/ar 不支援這個功能 -T 這個參數,有可能是因為 binutil 版本太舊,所以只要升級到 binutils-2.23.1 即可。

問題二: 未指定 link libcurses

錯誤訊息: LINK(target) xxx/v8/src/out/ia32.release/d8
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../libreadline.so: undefined reference to `tgetnum'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../libreadline.so: undefined reference to `tgetent'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../libreadline.so: undefined reference to `tgetstr'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../libreadline.so: undefined reference to `tgoto'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../libreadline.so: undefined reference to `UP'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../libreadline.so: undefined reference to `BC'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../libreadline.so: undefined reference to `tputs'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../libreadline.so: undefined reference to `PC'
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../libreadline.so: undefined reference to `tgetflag'
解決方式就要在 v8 編譯的時候,指定 link libcurse

修改檔案: trunk/out/src/d8.target.ia32.mk , 將 -lcurse 加入至 LIBS 這個參數。

d8.target.ia32.mk
  1. LIBS := \
  2. -lreadline\
  3. -lcurses

相關資料


回應 (Leave a comment)