André Selmanagić

about programming, games and tools

Compiling a NPAPI-Plugin from the Mozilla source-code

Some days ago I tried to compile the basic NPAPI-Plugin from the Mozilla codebase and of course ran into some problems that could easily be solved, though finding the answers wasn’t that easy.

Here’s the first one, when compiling:

c:\program files\microsoft sdks\windows\v7.0\include\winnt.h(6361): error C2146: syntax error : missing ';' before identifier 'ContextRecord'

Huh? winnt.h. Shouldn’t change something in there. I googled a little and someone knew the problem. He suggested to alter npplat.h and move some includes after the include of windows.h. Though this will work, it doesn’t actually sound like something you’re supposed to do. So I digged further and checked out the Gecko-Win32-Plugin-Samples-Package that you can get at MDC. The basic plugin in there compiled fine, which confused me a little, so I diffed the project-files and there I found the solution: The project-file from comm-central missed the preprocessor-tag _X86_.

I used some XPCOM-Components in my plugin, which lead to another compile-error:

nsidomnode.h(94) : error C2059: syntax error : 'constant'

I found someone in the net, having the same problem. Seems there is a #define GetNextSibling GetWindow somewhere in windows.h, which collides with the method-declaration of GetNextSibling in nsidomnode.h. So I undef’ed it after including windows.h and got the problem solved.