Standalone XPCOM

Warning: The content of this article may be out of date. These instructions were last updated in 2000.

Standalone XPCOM is a tree configuration that builds a minimal set of libraries (shared mostly) that can be used to get all features of XPCOM. The contents of this standalone XPCOM in general are:

  • NSPR : mozilla/nsprpub
  • XPCOM : mozilla/xpcom

NOTE 1: XPCOM APIs are not frozen yet. By XPCOM 1.0 release they will be.

NOTE 2: XPCOM Standalone differs from the XPCOM built with Mozilla. Hence cannot be used with the Mozilla browser.

Building Standalone XPCOM

Here are the instructions for building the Standalone XPCOM on Unix or Windows:

Step 1 : Pull the sources

  1. <tt>cvs -z 3 co mozilla/client.mk</tt>
  2. <tt>cd mozilla</tt>
  3. <tt>gmake -f client.mk pull_all BUILD_MODULES=xpcom</tt>

Step 2 : Build XPCOM Standalone

  1. <tt>./configure --enable-standalone-modules=xpcom --enable-application=standalone</tt>
  2. <tt>gmake</tt>

Testing Standalone XPCOM

<tt>xpcom/sample</tt> contains a sample application and a component. This should get built by default.

  • <tt>nsTestSample</tt> is the sample application. This should have been installed in your <tt>bin/</tt> directory.
  • <tt>libsample.so (unix) </tt>is the sample component implementation that the sample application will try to instantiate. This should have been installed in your <tt>bin/components</tt> directory

To run the test,

  1. cd to your <tt>bin/</tt> directory
  2. setenv LD_LIBRARY_PATH .
  3. <tt>./nsTestSample</tt>
    <tt>Warning: MOZILLA_FIVE_HOME not set.</tt>
    <tt>nsNativeComponentLoader: autoregistering begins.</tt>
    <tt>nsNativeComponentLoader: autoregistering succeeded</tt>
    <tt>Inital print: initial value</tt>
    <tt>Set value to: XPCOM defies gravity</tt>
    <tt>Final print : XPCOM defies gravity</tt>
    <tt>Test passed.</tt>

Test FAILED: What went wrong?

The most common case of why the sample would have failed if you didn't run it from the bin directory. Here are some error messsages and possible ways of fixing them.

<tt>./nsTestSample: error in loading shared libraries: libxpcom.so: cannot open shared object file: No such file or directory</tt>
LD_LIBRARY_PATH not set. To fix, <tt>setenv LD_LIBRARY_PATH .</tt> (note the dot).
Link errors when building XPCOM standalone
This is usually due to XPCOM not being built standalone. Make sure you did <tt>configure --enable-standalone-modules=xpcom</tt>.

What's the difference between Standalone and non-Standalone XPCOM?

There is no binary difference between standalone XPCOM and the XPCOM that ships with the Mozilla browser. The one functional difference is that XPT files cannot be read from .zip files in standalone XPCOM.

TODO for v 1.0

  1. Optional exclusion of specific features into standalone XPCOM like registry, xpconnect. Tweeking these options will cause reduction in memory requirements and size.
  2. Get <tt>xpcom/tests</tt> directory upto date and documented.
  3. Update this document for Mac.
  4. API freeze and documentation


Original Document Information

  • Author: Suresh Duddi
  • Last Updated Date: 15 May 2000
  • Copyright Information: Portions of this content are © 1998–2007 by individual mozilla.org contributors; content available under a Creative Commons license | Details.

Document Tags and Contributors

 Contributors to this page: teoli, Mgjbot, Nickolay, Jorend
 Last updated by: Mgjbot,