aaronsu 寫:
大家好,
因為我最近在學習如何撰寫XPCOM Component,我是參考以下這篇教學文章:
[How to Build an XPCOM Component in Javascript]
http://developer.mozilla.org/en/docs/Ho ... Javascript我也確實根據上面的步驟來做,
寫好helloworld.idl檔,並下載Gecko SDK來將他編譯為xpt檔,
然後將寫好的helloworld.js檔丟到
我的Mozilla Firefox\components 資料夾裡面,
然後在網頁上利用範例最後的方法來呼叫我剛剛寫好的xpcom component,
但一執行網頁,卻什麼東西都沒有顯示出來(我想若成功,至少會顯示hello world!這串文字),
所以想問問看大家有沒有是成功的呢?
ps.我的環境是windowx xp,然後mozilla firefox是直接安裝的。
感謝各位!
xpcom 放到 firefox 中測試比較麻煩,component 可以放進 一個extension中 component folder中,安裝後extension後,xpcom也會自動安裝。
xpcom 放進 xulrunner 測試較為方便,每次更改 application.ini中的 BuildID後(每次將數字改大一點),重開 xulrunner 便可更新。
example: 執行 run.exe
http://www.sun-club.org/passerby/hello_world_xpcom.exe
hello_world\components 放了 js xpcom script
refs:
http://developer.mozilla.org/en/docs/Getting_started_with_XULRunner
Download XULRunner 1.8 for Windows
http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/1.8.0.4/win32/en-US/xulrunner-1.8.0.4.en-US.win32.zip
Download XULRunner 1.9 for Windows (trunk)
http://ftp.mozilla.org/pub/mozilla.org/xulrunner/nightly/latest-trunk/
另外關於C++ xpcom,如果你真的用VC++2005 express (不是VC2005正式版本)去compile mozilla developer center example的話,你會發覺 compile中途會有error,因為 VC++2005 express 是不能開發 window application,
msdn的解決方法是安裝 Microsoft Platform SDK再修改一大堆設定,不過我告訴你一個簡單的方法,將
Microsoft Platform SDK下的bin、lib、include 複製到
C:\Program Files\Microsoft Visual Studio 8\VC (這是VC2005 express的預設位置),便能正常 compile了。
http://developer.mozilla.org/en/docs/How_to_build_a_binary_XPCOM_component_using_Visual_Studio
http://blog.csdn.net/chinesejimmy/archive/2007/06/01/1634075.aspx
xulrunner & xulrunner sdk & vc++ express project source file & xulrunner application example
http://www.sun-club.org/passerby/xulrunner_and_sdk_example.exe
file description:
xulrunner\xpcom-test <------- c++ xpcom source code
xulrunner\gecko-sdk <--------- xulrunner sdk & wintool
xulrunner\tests <----------- xulrunner application example
xulrunner\tests\components<-----------xpcom的dll、xpt放在這裡