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!