grr -- anyone experienced in building Firefox plugins in C++, on Windows / OSX?

topic posted Thu, January 10, 2008 - 9:55 PM by 
Share/Save/Bookmark
Advertisement

I feel so stupid. I'm a professional C++ developer, and i've been doing it for years and years. Now I have to write a Firefox plugin (NPAPI) in C++, which sounded easy enough, but after 2 days, I just can't get anything built. The documentation on developer.mozilla.org is often very confusing, a lot of info doesn't seem to be there at all, and i'm growing more frustrated by the day. This is _supposed_ to be easy. Writing an ActiveX control using the ATL in C++ for IE is dead simple to me (i've done it literally dozens of times over the years), but writing a plugin in C++ for Firefox is proving to be quite a frustrating endeavor. Searching the archives of the Mozilla dev-tech-plugins list only shows a few others complaining like I am, with no responses offered. The samples in the mozilla tree don't seem to build much of anything, no DLLs / bundles are generated on Windows / Mac OSX (the two platforms I need to target the most) ... sigh.

Can anyone point me to a code sample (hopefully simple for the obviously brain-dead developer I am) for a Firefox plugin that is known to build on Windows and OSX? What steps did you take to build it, and how did you install it?

Regards,

John

Falling You - exploring the beauty of voice and sound
www.fallingyou.com

posted by:
Advertisement
Advertisement
  • Hey John,

    I went through your same pain last year. I needed top write a Firefox plugin for OS X that couldn't be done through Javascript. It is a huge pain in the ass, and not all that well supported on Macintosh. The SDK is...a bit...uh...lacking. And, as you've found out, very little documentation and almost zero support from Mozilla or the developer community. My postings on the Mozilla Developer forums for help with writing a plugin in C++ yielded a total of 0 responses.

    Your best bet is to really, really try to do what you want in Javascript. You then have access to the UI engine and to many library classes. Going the C++ route means writing some very hairy code in their COM-like syntax using C++ bindings, and then probably having to write Javascript bindings on top of that.

    Hope this helps a little (probably not, but oh well).

    doug

    • Doug,

      Alas, what I have to do (start a process on the machine), JavaScript can't do ... I need to implement a new MIME type handler, and this basically has to call the equivalent of fork() on *nix or CreateProcess() / ShellExecuteEx() on Win32 when a certain <object> is specified in HTML. The last I checked, JavaScript couldn't do that. I remember doing a bit of XPCOM a few years ago, and as I remember it was somewhat COM-like (and since i've done a ton of ActiveX / ATL on Windows, XPCOM wasn't too difficult). My biggest issue with Mozilla / FF right now is that their plugin dev documentation doesn't say _how_ to build (read: compile and link) a plugin, and the plugin sample code in the Mozilla source tree doesn't seem to generate a whole helluva a lot when you just run "make". Sure, it seems to build something, but is it a DLL on a Windows box? No, it's a lib. Does the same process build anything at all under OSX? No, though Mozilla's OSX build process, funnily enough, seems to generate a "windows" directory under the sample plugin directory (and this is on a Mac), and trying to compile the sample in this "windows" directory gives errors about things like LRESULT and windows.h -- in other words, it's Windows code. Why building Mozilla under OSX generates a plugin sample that can only be built on a Windows box is a good idea is lost to me.

      I know it can be done -- the RealPlayer and QuickTime player plugins, not to mention the PDF reader plugins, do exactly what I need to do ... but i've no idea how those developers actually compiled / linked / installed those plugins, and the Mozilla developer documentation so far is _really_ spotty in this regard.

      Regards,

      John

      Falling You - exploring the beauty of voice and sound
      www.fallingyou.com




    • DJ Fitz,

      Now _this_ is funny ... I searched the Apple ADC site for "NPAPI" and lo, I found a plugin sample that I was actually able to -- gasp -- build, and -- shock, horror -- deploy. I only tested it on Safari, but if I install it in the right place, i'm sure it will work with Firefox. This at least shows me that I can do what I need to do (call BSD or Cocoa functions / methods on OSX, and Win32 functions on Windows). Now I just need to figure out how to do it on Windows ...

      Regards,

      John

      Falling You - exploring the beauty of voice and sound
      www.fallingyou.com

Recent topics in "C++"