Building Firefox Plugins using Visual Studio

by APIJunkie 9/22/2008 12:59:00 AM

If you are in the business of writing components/plugins that work inside browsers and even if your target audience is Windows users, you can't ignore Firefox anymore.

IE is still the most popular browser by far but Firefox is a force to reckon with when it comes to writing browser plugins.

If you use Visual studio as a development environment and want to develop plugins for Firefox here are a few points to get you started.

First checkout the article OpenGL sample as Firefox plugin on code project. It is a great and simple example on how to write a Firefox plugin.

Second, because some things have changed since the above article was written, follow the steps below to get the Firefox plugin project to work on Visual Studio:

1. Download the Firefox source code version you want

    Example: the Firefox 3.0.1 version is found here

2. Extract to yourroot\mozilla

   Example C:\Projects\XProj\mozila

3. Download the Gecko SDK/ XULRunner SDK source code version you want

    Example: the Gecko 1.9 (Firefox 3.0) version is found here

4. Extract to yourroot\xulrunner-sdk(for Firefox version 3.0) or yourroot\gecko-sdk(for Firefox version 1.5-2.0)

   Example C:\Projects\XProj\xulrunner-sdk

5. Run unix2dos on npbasic.dsp and npbasic.dsw (you can find them at yourroot\mozilla\modules\plugin\tools\sdk\samples\basic\windows)

6. Open the npbasic Visual Studio project (you can find it at yourroot\mozilla\modules\plugin\tools\sdk\samples\basic\windows)

7. Inside Visual Studio go to project properties and set the additional include directories:

For Firefox 1.5-2 (gecko-sdk) change to->

yourroot\gecko-sdk\include; yourroot\mozilla\modules\plugin\tools\sdk\samples\include

For Firefox 3 (xulrunner-sdk) change to ->

yourroot\xulrunner-sdk\sdk\include; yourroot\mozilla\modules\plugin\tools\sdk\samples\include

8. Fix a compilation bug in npplat.h:

When building the project you might receive the following error:

error C2146: syntax error : missing ';' before
identifier 'ContextRecord'

The error can be fixed by changing the order of some of the include files inside npplat.h.

The following 2 include lines are found in npplat.h:

#include "npapi.h"

#include "npupp.h"

You will need to move them from the beginning of the npplat.h to a place beyond where the Windows include files are included.

For Example if the original file looks like this:

...

#ifndef _NPPLAT_H_

#define _NPPLAT_H_

#include "npapi.h"

#include "npupp.h"

/**************************************************/

/* Windows */

/**************************************************/

#ifdef XP_WIN

#include "windows.h"

#endif //XP_WIN

...

The modified file should look like this:

...

#ifndef _NPPLAT_H_

#define _NPPLAT_H_

/**************************************************/

/* Windows */

/**************************************************/

#ifdef XP_WIN

#include "windows.h"

#endif //XP_WIN

#include "npapi.h"

#include "npupp.h"

.....

 9. Rebuild the project.

10. You should be good to go now. Good luck!

 

Currently rated 4.5 by 4 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

C++ | How To | Firefox

Powered by BlogEngine.NET 1.2.0.0
Theme by Mads Kristensen

About the author

Name of author

My name is Bacon…James Bacon.

I am an API wars veteran I was wounded by x86 assembly, recovered and moved on to C. Following a long addiction to C++ and a short stint at rehab I decided to switch to a healthier addiction so I am now happily sniffing .NET and getting hooked on Silverlight.

I am mainly here to ramble about coding, various API’s, Junkies(me especially) and everything else that happens between coders and their significant other.

E-mail me Send mail


Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Sign in