linking libraries with mozilla xpcom

/space/mozilla.pngff_icon.png/space/camino.png/space/thunderbird.jpg/space/bugzilla.jpg

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!

See also:

4 Comments

  1. 2/28/2006 #

    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: 0×80570015 (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. 3/2/2006 #

    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. Lukas durfina
    10/25/2007 #

    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. Long
    11/18/2007 #

    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.

Post a Comment

Post a comment...

Your email is never published nor shared.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


  • home
    about
    pictures
    software
    index
    feed