Skip to main content
Compiling The npruntime Sample Plugin in Visual Studio
From MDC
[edit] General decisions
- filename of DLL
must start with "np" (not "ns") and ends with ".dll" (I wasted hours on this - repeatedly)
- mimetype
reflects the data type handled by the plugin. this is how webpages invoke your plugin. should either be like "application/x-vnd-yourorganization-yourfiletype" or be officially registered with IANA (unlikely) or be a standard type (e.g. if you want to play MPEG files).
- file extension
reflects the data type handled by the plugin, esp. when loaded from local disk on Windows.
- Create a new project in Visual Studio for a Win32 GUI library (DLL) (in .NET 2003: Win32 template, then switch to DLL in Application Settings in the following dialog, export symbols too?)
- Again note that the resulting DLL filename must start with "np", so either call your project like this or rename the file later
- Delete the .cpp and .h and ReadMe files from the project and disk
- Copy the npruntime sample plugin source code into the dir of the new VS project and add the files to the project using the VS GUI (.cpp files to "Source Files", .h files to "Header Files", .rc file to "Resource Files"). Samples can be obtained from: http://developer.mozilla.org/en/docs/Plugins:_Samples_and_Test_Cases
- Download the Gecko SDK from mozilla.org release FTP and extract it. You can download it from here: http://developer.mozilla.org/en/docs/Gecko_SDK
- Add the Gecko SDK include path to
Project Properties|(all configurations)|C++|General|Additional Include Directories
- Add the following preprocessor definitions to
Project Properties|(all configurations)|C++|Preprocessor|Preprocessor Definitions: WIN32;_WINDOWS;XP_WIN32;MOZILLA_STRICT_API;XPCOM_GLUE;XP_WIN;_X86_;NPSIMPLE_EXPORTS
- Disable precompiled headers using
Project Properties|(all configurations)|C++|Precompiled headers|Create/Use precompiled header
- Define the function exports by adding the .def filename (e.g. nprt.def) to
Project Properties|(all configurations)|Linker|Input|Module Definition File
- Open the above .def file and change "NPRT" to the filename of your dll as VS sees it (without "np", if you decided to rename later)
- Edit the .rc file and and the top of npp_gate.cpp for the description, mimetype, file extension etc. to reflect your plugin
- Remove the function
NPP_GetJavaClass from npp_gate.cpp
- Build
- Rename the resulting DLL so that the filename starts with "np" and ends with ".dll" (or "32.dll"? 8.3?) and copy it in Mozilla's "plugins" folder
- Start Mozilla and open <about:plugins>
[edit] Original Document Information
- Author(s): Ben Bucksch
- Copyright Information: ManyOne