When you create a project for Visual studio there are a couple of key steps that are highlighted here from the original guild from Mozilla “Compiling The npruntime Sample Plugin in Visual Studio”
From the build steps listed in the article from Mozilla,
- Create a new project in Visual Studio. Make sure that you create a generic Win32 Project.
- In the application setting, select a DLL project and make sure to check the “empty Project” check-box.
- Steps 4& 5 – If you have created an empty project, you will not have to delete any files. Add the npruntime source files that you download from Mozilla.
- steps 6 & 7 – You will need the xulrunner SDK to build the project. After downloading and installing the SDK you will need to point the include paths to build the NPAPI plugin.
- step 8 you will need to add the correct preprocessor defines to build properly.
- step 9 – if you have created an empty project, the pre-compiler headers should be disabled.
- An omitted step is the addition of the library paths for the linker to find the xulrunner-sdk libraries.
- step 10 – add the module definition file to the project. This is important to export the proper NPAPI functions needed to load the plugin in the browser.
that should be enough to build the control at this point. From here you would want to continue with the Mozilla link to configure the plugin MIME type string so you can define your own data type for the control to use.
If you try to build the project at this point, it will fail with errors. As the Mozilla and Gecko SDK’s have evolved, this sample has not been kept up to date which is disappointing.
To fix the problems you will need to do the following:
- The control should be compiled with UNICODE enabled. Otherwise older browsers such as Firefox will not properly load the plugin if the absolute path to the plugin contains spaces.
- Visual Studio does not properly handle the C99 standards about the int32_t and other C99 types. You will have to manually update the code to get around this issue. Change integer types (int16, int32, uint16, uint32) to use the new modern prototypes (int16_t, int32_t, uint16_t, and uint32_t). As Gecko evolved, the data types changed. The sample code was never updated and won’t compile without these changes.
- change headers. The old header “npupp.h” has been replaced by “npfunctions.h”. Mozilla – Bug 455458 covers the change to these headers. This was done back in 2008 with Gecko 2.0 (Firefox 4).
- fix property setter method. There is a bug with the sample code when you process a property and set a value.
- debugging with Firefox: attach the debugger to the app “plugin_container.exe” and this will let you debug your code within visual studio. Be careful! if you take too long, Firefox will think the plugin crashed and kill the app and end your session.
- Debugging with Chrome: This is a lot like debugging with IE. Chrome launches a new Chrome process to contain the plugin, so you need to figure out which process belongs to the plugin and attach the debugger to that process. Typically this is the Chrome process with the highest process ID as reported by Visual Studio.
If you get to this point, you should have a Visual studio project that you can build.