Static xpidl.exe compiled on .NET (VC) 2005 Express

It would be wonderful that we could have a static linked xpidl.exe <font color="red">without</font> needing any additional DLLs:

  • libIDL-0.6.dll
  • glib-1.2.dll
  • msvcr80.dll and msvcrt.dll

The static xpidl.exe is compiled by VC 2005 Express on XP SP2 and only needs ADVAPI32.DLL and KERNEL32.DLL which are installed on any XP system.

You will definitely need to have either Visual Studio 2005 or VS 2005 Express installed to run the "static" binary. This is caused by new Microsoft brain-damage called side-by-side (sxs) assemblies and manifest file which reference these assemblies. Even in "static" exes the compiler will embed a manifest to (I assume) reference the sxs version of the c runtime. Without these extra files, trying to run this "static" file will fail with the error

this application has failed to start because the application configuration is incorrect

Belphanior 12:49, 4 December 2006 (PST)

Possible Solution

Download Link .tgz file md5-signed file
Binary only xpidl.exe.static.tgz 180K xpidl.exe.static.tgz.md5
Source Package xpidl-static.tgz 2.80M xpidl-static.tgz.md5

How to make this package?

It's better to see Windows_Build_Prerequisites and Build first
  • 1. Download and extract xulrunner- and VC8 static tools vc8-moztools.zip
  • 2. Create build dir(like xpidl-static) and copy moztools/* to it.
  • 3. Build nsprpub in cygwin on windows with VC 2005 Express cl.exe and link.exe. see Build
  • 4. Copy the nsprpub\dist{bin,include,lib} to this dir.
  • 5. Copy the orginal mozilla\xpcom\typelib to this dir.
  • 6. Modify the include\nspr\prtypes.h in line 230-231 to the following.
226 #if defined(_NSPR_BUILD_)
227 #define NSPR_API(__type) PR_EXPORT(__type)
228 #define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
229 #else
230 #define NSPR_API(__type) <font color="blue">__type //PR_IMPORT(__type) </font>
231 #define NSPR_DATA_API(__type) <font color="blue">__type //PR_IMPORT_DATA(__type) </font>
232 #endif

If not, you will meet __imp__PR_XXX unreference variable when building xpidl. That's because if define PR_IMPORT, any function will be mingled to _imp__ in dynamic link. For details please see Function-Attributes (dllexport & dllimport).

  • 7. Modify the xpt\src\xpt_struct.c
259 //fputs("libxpt: File length in header does not match actual length. File may be corrupt\n",
260 //    stderr);  // ypwang modified for static-compiling on VC 2005 express 
261 fprintf(stderr, \
262      "libxpt: File length in header does not match actual length. File may be corrupt\n");

If not, you will meet __imp__fputs unreference varialble when building xpt_link That's because __imp__fputs is in the MSVCRT8.dll, but if we change to fprintf, we will get rid of that DLL without losing anything. It's worthy, isn't? :-)

  • 8. Create VC 2005 express projects and set properties of the each project. Just open and see it I don't wanna waste space writing here :-)