XPCOM

all about XPCOM

2006-08-26 Static xpidl.exe compiled on VC 2005 Express

After downloading the gecko-sdk 1.8b for creating a simple xpcom component, I didn’t foresee that I would spend nearly 3 days on it. The first two missing DLL needed by xpidl.exe cost me minutes to find but the third one spends me hours to get it work. So it would be wonderful that we can have a static linked xpidl.exe without needing any additional DLLs. There it is. The static xpidl.exe is compiled by VC 2005 Express on XP SP2 and only needed ADVAPI32.dll and KERNEL32.DLL which are installed on any XP system.

 

Begin your xpcom adventure from static xpidl.exe and have fun!

 

Download

static xpidl.exe:

xpidl.exe.static.tgz(only tested on XP SP2) and md5- xpidl.exe.static.tgz.md5

Source package:

xpidl-static.tgz and md5- xpidl-static.tgz.md5

Readme in Source package:

How to make this package?

0. Download the xulrunner-1.8.0.4-source.tgz
1. Build nsprpub in cygwin on windows with VC 2005 Express cl.exe and link.exe
2. Copy the dist\{bin,include,lib} to this dir.
3. Copy the orginal mozilla\xpcom\typelib to this dir.
4. 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) __type //PR_IMPORT(__type)
231 #define NSPR_DATA_API(__type) __type //PR_IMPORT_DATA(__type)
232 #endif
 
   If not change, 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 http://developer.apple.com/documentation/DeveloperTools/gcc-4.0.1/gcc/Function-Attributes.html (dllexport & dllimport).

5.  Modify the xpt\src\xpt_struct.c

        //fputs("libxpt: File length in header does not match actual length. File may be corrupt\n",
        //    stderr);  // ypwang modified for static-compiling on VC 2005 express
        fprintf(stderr, \
  "libxpt: File length in header does not match actual length. File may be corrupt\n");

 

        If not change, 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? :-)

6.  Create VC 2005 express projects and setting the each projects properties. Just open you will see it, I don't wanna waste space writing here.


BTW, At first I just want to build on cygwin+gcc-3.4.4(the latest version) but I failed to build nsprpub, then I gave up. If you know the method I am very happy to hear from you :-).

Any questions and suggestions could be sent to me on ypwangandy@_NO_SPAMgmail.com 

Have fun!