您的位置:首页 > 运维架构 > Linux

跨浏览器插件框架FireBreath安装与使用之二——Linux下的插件

2012-09-15 15:07 337 查看

跨浏览器插件框架FireBreath安装与使用之二——Linux下的插件

cheungmine2012-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 [b]./projects/hello[/b]
$ 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.

熬夜搞了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})一切大功告成。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: