Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to start writing XPCOM C++ add-on?

132 views
Skip to first unread message

gpee...@gmail.com

unread,
Jul 25, 2013, 7:53:20 PM7/25/13
to
Hi there,

I've spent already two days trying to understand the documentation and force to work mozilla build system with no luck.
It seems that mozilla documentation is ridiculously out-dated and sparsed (most of documents are 4-5 years old)!! I've started with this tutorial [1] and ended up with errors - it turned out that mozilla recently changed it's build system [2][8] for using moz.build files. So I've updated my files in add-on directories to moz.build, but invoking "make -f client.mk build" still doesn't want to simply generate stub header/cpp files from idl description!
This [3] documentation is obsoleted as well.
This one [4] doesn't show how exactly I should compile my extension (or it does? where?).
This [5] doesn't say anything how to use xpidl compiler (which is turned out to be replaced by pyxpidl [6] now). I've tried to build Xulrunner SDK and find out how to use idl compiler [7] but all I get instead of cpp header is this:
"XPCOM
TypeLib

à $ \Ä Ü≠fÈ≥˜NjæÓÄ+ üÙB
nsISupports INertc Add Ä Ä ` Ä Ä"

It seems that I know a lot about how mozilla works and what components it has, except simple information about how to build the simplest C++ add-on!

Moreover, mozilla add-on developer's forum doesn't want to log me in, though I've created AOM account and activated it already...

I'm crying for help in this topic! Can anyone explain which steps I should undertake in order to create the simplest add-on in C++ which provides interface through XPCOM to the outer web-app world? So in the end, I could just create an instance of it in JavaScript code on a web-page and call its method "helloWorld"?
Will highly appreciate any help on this topic.

[1] https://developer.mozilla.org/en-US/docs/Creating_Custom_Firefox_Extensions_with_the_Mozilla_Build_System
[2] https://developer.mozilla.org/en-US/docs/How_Mozilla%27s_build_system_works
[3] https://developer.mozilla.org/en-US/docs/Firefox_addons_developer_guide/Let%27s_build_a_Firefox_extension
[4] https://developer.mozilla.org/en-US/docs/Creating_XPCOM_Components
[5] http://books.mozdev.org/html/mozilla-chp-8-sect-2.html
[6] https://developer.mozilla.org/en-US/docs/XPIDL/pyxpidl
[7] https://forums.mozilla.org/addons/viewtopic.php?p=12691&sid=e766d9ded9b9f7b822e699d031fd42e4
[8] http://gregoryszorc.com/blog/2013/02/28/moz.build-files-and-the-firefox-build-system/

sande...@gmail.com

unread,
Sep 12, 2013, 7:23:49 AM9/12/13
to
Hi,
I am also having problem starting XPCOM. I saw your post but there are no replies. Were you able to work on it? If so please let me know what should I follow.

Hoping for your reply

Sandeep

gpee...@gmail.com

unread,
Sep 16, 2013, 2:12:38 PM9/16/13
to
Hi Sandeep,

Please, check out this post http://stackoverflow.com/questions/17822669/firefox-add-on-in-c and this one http://ptncode.blogspot.com/2013/08/exposing-xpcom-c-interface-on-dom.html

And let me know if you have any further questions

Cheers,

jka...@gmail.com

unread,
Oct 6, 2013, 11:37:11 AM10/6/13
to
On Thursday, July 25, 2013 4:53:20 PM UTC-7, gpee...@gmail.com wrote:
> Hi there,
>
>
>
> I've spent already two days trying to understand the documentation and force to work mozilla build system with no luck.
>
> It seems that mozilla documentation is ridiculously out-dated and sparsed

*** Indeed. I wanted to build a simple XPCOM module to control a local scanner. After a week of part time fussing around trying to just get a "hello world", I gave up and just decided to code my thing in Perl/Tk. Foo.

The best and most up to date "documentation" I found on XPCOM was in the current Mozilla source. There's a directory called xpcom, and inside that a directory called "sample", with a reasonably well commented idl file and C++ code. I was able to compile the whole firefox source, including that sample without too much pain, using the "mach bootstrap" and "mach build" commands. This was on a five year old Ubuntu 12.04 Linux box. Took a couple hours.

The IDL output wound up in an "obj-(bunch of stuff)" directory at the top of
the mozilla tree. Inside that directory was a "xpcom/sample" directory with the IDL output in there somwhere and also the compiled XPCOM object ( I think ) and a test program - which crashed and burned when I ran it. There was also a
Makefile in this output area, and I was able to make changes to the sample back in the source and recompile just that by saying "make" in the obj directory.

The sample at www.iosart.com/firefox/xpcom/ is totally out of date and unusable - at least by me.

I might go back to this when I get some time. I don't think the difficulties are insurmountable. I could do many marvelous things with access
to native machine resources from Firefox.

0 new messages