本文介绍了有人使用第三方库以包含在Firefox插件/扩展中如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在学习如何使用XPCOM创建Firefox插件,我想知道如何包括第三方库来开发它们。我按照几个教程从c ++文件中编译.xpt和.dll(注释:和),我不知道我们如何将这些文件包含到一个addon项目(它被打包成.xpi文件)。



我使用Opencv(c ++)通过插件进行图像转换,例如将非常大的图像(3mb高分辨率)调整到一些小而简单的格式(例如600X800 200kb jpg )将由我的插件。我知道Opencv是用c ++编写的,xpcom可以将c ++代码编译成dll和xpt。我读了几个教程,但大多数都指向在C:/ Program Files(x86)/ Mozilla Firefox /组件而不是addonscomponents /文件夹中添加这些文件(xpt和dll)附件工作,我相信)。虽然Mozilla页面(上面列出)包含了关于{app} / components和{app} /application.ini文件夹的内容,但我从来没有读过这样的内容,所以我很困惑这是怎么做的。 / p>

我的另一个选择是将Opencv方法变成可执行文件,然后单独运行它(类似于MemoryFox addon运行可执行文件以清除Firefox的内存),并使用它来执行映像调整大小。



我真的不知道如何做到这一点(我是新的addon开发),我想知道如何完成这个(使用第三方C ++ libs到插件)。



提前感谢。



编辑:I也希望通知我已阅读了大部分的应该是一个很好的起点 - 这应该解释你需要写什么。



请注意,你正在阅读的教程中的源代码是过时的好。当前代码示例链接到。您应该使用XULRunner SDK 2.0(对应于Firefox 4)或更高版本。对不起,你来到一个坏的时间 - 这是过去十年XPCOM最大的变化。


I am currently learning how to create Firefox addons using XPCOM and I want to know how to include thirdparty libraries to develop them. I followed a few tutorials to compile .xpt and .dll from c++ files (noted in: https://developer.mozilla.org/en/How_to_build_a_binary_XPCOM_component_using_Visual_Studio and http://nerdlife.net/building-a-c-xpcom-component-in-windows/) and I am not sure how we are suppose to include the files into an addon project (which gets packaged into .xpi file).

I am using Opencv (c++) to do image conversions via the addon such as resizing a very large image (3mb high res png) down to something small and simple (such as 600X800 200kb jpg) that will be done by my addon. I know that Opencv is written in c++ and xpcom can compile c++ code into a dll and xpt. I read a couple of tutorials but most of them points to adding these files (xpt and dll) in "C:/Program Files(x86)/Mozilla Firefox/components" instead of the addons "components/" folder (which is not how addons work, I believe). Though the Mozilla page (listed above) does include something about "{app}/components" and "{app}/application.ini" folders but I have never read anything like this, so therefore I am confused how this is done.

My other option is making the Opencv methods into an executable and then running it separately (similar to how MemoryFox addon runs an executable to clear Firefox's memory) and use that to conduct image resizing.

I am really not sure how to do this (I am new the addon development) and I would like to know how to accomplish this (using 3rd party C++ libs into the addons). An example, tutorial or explanation is fine to get me started.

Thanks in advance.

Edit: I would also like to inform that I have read threw most of https://developer.mozilla.org/en/Creating_XPCOM_Components (picked and choose topics) and it does not tell me how to achieve the above.

解决方案

The tutorial you refer to is about developing applications, not extensions. So application.ini doesn't apply in your case. Extensions have a manifest file called chrome.manifest, starting with Firefox 4 all XPCOM components and XPT files need to be registered there - or they will be ignored. It no longer matters where the component is located though components/ would still be the common place for them. https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0#Component_registration should be a good starting point - that should explain what you need to write there.

Note that the source code in the tutorials you were reading is outdated as well. Current code examples are linked to from https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0#Binary_components. And you should use XULRunner SDK 2.0 (corresponds to Firefox 4) or higher. Sorry, you arrived at a bad time - that's the biggest change to XPCOM in the past 10 years.

这篇关于有人使用第三方库以包含在Firefox插件/扩展中如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 05:00