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
- cvs -z 3 co mozilla/client.mk
- cd mozilla
- gmake -f client.mk pull_all BUILD_MODULES=xpcom
Step 2 : Build XPCOM Standalone
- ./configure --enable-standalone-modules=xpcom --enable-application=standalone
Testing Standalone XPCOM
xpcom/sample contains a sample application and a component. This should get built by default.
- nsTestSample is the sample application. This should have been installed in your bin/ directory.
- libsample.so (unix) is the sample component implementation that the sample application will try to instantiate. This should have been installed in your bin/components directory
To run the test,
- cd to your bin/ directory
- setenv LD_LIBRARY_PATH .
Warning: MOZILLA_FIVE_HOME not set.
nsNativeComponentLoader: autoregistering begins.
nsNativeComponentLoader: autoregistering succeeded
Inital print: initial value
Set value to: XPCOM defies gravity
Final print : XPCOM defies gravity
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.
- ./nsTestSample: error in loading shared libraries: libxpcom.so: cannot open shared object file: No such file or directory
- LD_LIBRARY_PATH not set. To fix, setenv LD_LIBRARY_PATH . (note the dot).
- Link errors when building XPCOM standalone
- This is usually due to XPCOM not being built standalone. Make sure you did configure --enable-standalone-modules=xpcom.
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
- Optional exclusion of specific features into standalone XPCOM like registry, xpconnect. Tweeking these options will cause reduction in memory requirements and size.
- Get xpcom/tests directory upto date and documented.
- Update this document for Mac.
- API freeze and documentation