轉http://blog.csdn.net/ubuntu64fan/article/details/7982220
跨瀏覽器插件框架FireBreath安裝與使用之二——Linux下的插件
cheungmine
2012-9
關鍵詞:Linux, Plugin, Firefox
http://www.firebreath.org/display/documentation/Building+on+Linux
本文試圖用最清晰的步驟說明如何在Linux(Ubuntu Desktop)上安裝FireBreath開發環境,並通過一個完整的
示例插件項目hello,來說明如何開發Linux上的瀏覽器插件。
1)首先是在ubuntu desktop 12.04上安裝開發環境,安裝cmake, libgtk(大部分瀏覽器使用的圖形庫), git。
$ sudo apt-get install cmake libgtk2.0-dev git
2)下載firebreath最新版。當前目錄: ~/NVPACK。解壓縮。
git clone https://github.com/firebreath/FireBreath.git
$ cd ./FireBreath
當前目錄爲~/NVPACK/firebreath
$ mkdir ./projects
3)生成示例項目(此步是可選的)。
$ ./prepmake.sh ./examples
4)創建自己的插件:hello
$ python ./fbgen.py
在需要輸入名稱的地方輸入:hello
這樣一個hello plugin的源代碼就生成了。接下來生成項目build文件。
5)生成項目構建文件。因爲是用make構建,所以我們選擇:
$ ./prepmake.sh ./projects/hello
6)構建項目
$ cd ./projects/hello
$ make
7)部署和測試
插件文件nphello.so生成了,在:
../firebreath/build/bin/hello/nphello.so
把這個文件複製到Firefox插件路徑下:
/usr/lib/mozilla/plugins/
$ sudo cp ~/NVPACK/firebreath/build/bin/hello/nphello.so /usr/lib/mozilla/plugins/
然後用firefox瀏覽器打開下面的測試文件:
~/NVPACK/firebreath/build/projects/hello/gen/FBControl.htm
看到:
-----------------------
Plugin loaded!
-----------------------
[OK]
最近遇到一個問題,我在Linux上編寫繪圖插件,在包含#include "X11/PluginWindowX11.h"之後,系統提示:
- In file included from /home/cl/workspace/firebreath-git/firebreath-dev/projects/canvasplugin/canvasplugin.cpp:27:0:
- /home/cl/workspace/firebreath-git/firebreath-dev/src/PluginAuto/X11/PluginWindowX11.h:22:21: fatal error: gtk/gtk.h: No such file or directory
- compilation terminated.
In file included from /home/cl/workspace/firebreath-git/firebreath-dev/projects/canvasplugin/canvasplugin.cpp:27:0:
/home/cl/workspace/firebreath-git/firebreath-dev/src/PluginAuto/X11/PluginWindowX11.h:22:21: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.
熬夜搞了10個小時,終於搞定。在.../projects/canvasplugin/X11/projectDef.cmake里加入下面的內容:
- # solve make error:
- # src/PluginAuto/X11/PluginWindowX11.h:22:21:
- # fatal error: gtk/gtk.h: No such file or directory
- include_directories(${GTK_INCLUDE_DIRS})
# solve make error:
# src/PluginAuto/X11/PluginWindowX11.h:22:21:
# fatal error: gtk/gtk.h: No such file or directory
include_directories(${GTK_INCLUDE_DIRS})
一切大功告成。