linking libraries with mozilla xpcom

I’ve been doing some development recently on the Mozilla XPCOM platform, and it’s pretty cool. However, I ran into a small snag when I tried to build a C++ XPCOM component that linked with external libraries (specifically the X11 libraries).

Mozilla provides a way to build XPCOM components by hooking into their Makefiles, which is great…except that adding extra libraries to LIBS didn’t work. They were just ignored. If you need to link with external libraries, the trick is to add them to EXTRA_DSO_LDOPTS, not to LIBS.

As an example, I needed to add the flags -lX11 -L/usr/X11R6/lib to the link stage. I used the example XPCOM Makefile, and edited the EXTRA_DSO_LDOPTS line to look like this:

EXTRA_DSO_LDOPTS += \
  $(MOZ_COMPONENT_LIBS) -lX11 -L/usr/X11R6/lib

Voila, it worked!

5 thoughts on “linking libraries with mozilla xpcom

  1. Hi,
    I also had the same problem as you and I add libraries and header files in following variables

    EXTRA_LIBS

    LOCAL_INCLUDES

    Compiling and linking part is working fine. but when I try to make a object in JS it shows the following error:


    uncaught exception: 0x80570015 (NS_ERROR_XPC_CI_RETURNED_FAILURE) [nsIJSCID.createInstance” nsresult: “0x80570015 (NS_ERROR_XPC_CI_RETURNED_FAILURE)” location: “JS frame :: typein :: <TOP_LEVEL> :: line 3” data: no]


    Do you have some idea about this.
    thanx!

    – Dimuthu

  2. hey dimuthu! it’s been a while since i hacked on xpcom, so unfortunately, i can’t help you much. i’ll ping a friend who might know more, though.

  3. I am working on my bachelor work. I am developing a component
    with cooperate with some third party library and have same problem. I like to talk with people, who have some experience with this. My email: lukas [dot] durfina  [at] gmail [dot] org

  4. Please post here, I’m also having some strange behavior linking extra libraries to XPCOM.

    Specifically; dereferencing a pointer to an ofstream causes a segfault, but only when the library is used in an XPCOM component.  When it is linked into another application it works fine.

  5. Hi guys,

    Any solution for the above error NS_ERROR_XPC_CI_RETURNED_FAILURE.I get this when I run my app with xulrunner

Leave a Reply

Your email address will not be published. Required fields are marked *