Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: How to build xpcom component on Mac OS X?

45 views
Skip to first unread message

ramya lakshmi

unread,
Oct 11, 2006, 12:14:04 AM10/11/06
to dev-tec...@lists.mozilla.org
I could build the xpcom component on Mac using Firefox source code. Mozilla
code did not build successfully for me.
I downloaded firefox source code from:
ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/1.5.0.7/source/firefox-1.5.0.7-source.tar.bz2

The following site clearly explains how to build an XPCOM component:
http://developer.mozilla.org/en/docs/Creating_Custom_Firefox_Extensions_with_the_Mozilla_Build_System

If you could already build the component using mozilla source code its good
. Otherwise download firefox source code and follow the steps specified in
that URL.

If you have any problems building the component, i ll clearly give you all
the steps I followed.


>Now I have build the dylib successfully, but how to register it with
>Firefox?
>I put the t.dylib and t.xpt in /Applications/Firefox.app/Content/
>MacOS/components and start the firefox, but seems it can not load my
>component.
>Then I try the regxpcom like this:
>regxpcom -x /Applications/Firefox.app/Contents/MacOS/components .
>but it says "bus error"...
>
>在 2006-10-7,上午5:51,Jamie Newton 写道:
>
> > I have my component building working now for MacOSX. Heres my
> > makefile ( we
> > build mozilla from source so the SDK paths may be unfamiliar to
> > some). I
> > hope this will be of use to those who are still struggling
> >
> > PLATFORM := $(shell sh ../../../../../install/unix/cplatname identify)
> > SOURCEDIR := ../../../../../modules/ServerManager
> > OUTPUTDIR := ../../../../../apps/xena/components
> > DISTDIR :=
> > ../../../../../thirdparty/mozilla/$(PLATFORM)/mozilla/obj-xulrunner/
> > dist
> > SHAREDDIR := ../../../../../shared
> > GECKO_SDK := $(DISTDIR)/sdk
> > GECKO_DEFS := -DMOZILLA_STRICT_API
> > CXX := c++
> > CXXFLAGS := -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -fno-rtti
> >
> > INCLUDES := -I $(GECKO_SDK)/include -I $(SHAREDDIR)/XPCOM \
> >
> > LDFLAGS := -lxpcomglue_s -lxpcom -lnspr4 -lplds4 -lplc4 -lmozjs
> >
> > OBJECTS := ServerManagerImpl.o ServerManagerModule.o
> >
> > servermanager: $(OUTPUTDIR)/ServerManager.xpt
> > $(OUTPUTDIR)/ServerManager.dylib
> >
> >
> > $(OUTPUTDIR)/ServerManager.xpt: $(SOURCEDIR)/ServerManager.idl
> > $(GECKO_SDK)/bin/xpidl -m typelib -w -v -I $(GECKO_SDK)/idl -o
> > $(OUTPUTDIR)/ServerManager $(SOURCEDIR)/ServerManager.idl; \
> > $(GECKO_SDK)/bin/xpidl -m header -w -v -I $(GECKO_SDK)/idl -o
> > $(XPCOMDIR)/ServerManager $(SOURCEDIR)/ServerManager.idl; \
> > $(DISTDIR)/bin/regxpcom -x $(OUTPUTDIR); \
> > touch $(DISTDIR)/bin/.autoreg
> >
> > $(OUTPUTDIR)/ServerManager.dylib:
> > $(CXX) -Os -c -o ServerManagerImpl.o $(GECKO_DEFS) $(INCLUDES)
> > $(SOURCEDIR)/ServerManagerImpl.cpp $(CXXFLAGS)
> > $(CXX) -Os -c -o ServerManagerModule.o $(GECKO_DEFS) $(INCLUDES)
> > $(SOURCEDIR)/ServerManagerModule.cpp $(CXXFLAGS)
> > $(CXX) -dynamiclib -o $(OUTPUTDIR)/ServerManager.dylib $(GECKO_DEFS)
> > $(OBJECTS) -L$(GECKO_SDK)/lib -L$(GECKO_SDK)/../lib -Wl,-
> > executable_path,$(GECKO_SDK)/bin
> > $(LDFLAGS) -framework CoreFoundation -framework XUL
> >
> > clean:
> > rm -f $(OUTPUTDIR)/ServerManager.xpt
> > rm -f $(OUTPUTDIR)/ServerManager.dylib
> >
> > "Benjamin Smedberg" <benj...@smedbergs.us> wrote in message
> > news:5didnVqD9MSgvLzY...@mozilla.org...
> >> Keren Dong wrote:
> >>> Hi,
> >>>
> >>> I am trying build a xpcom sample from
> >>> http://www.iosart.com/firefox/xpcom/ on Mac OS X, and my makefile
> >>> is as
> >>> bellow:
> >>
> >> I'm not sure why people keep using this tutorial (perhaps because
> >> there's
> >> nothing better), but it is wrong in many ways. In particular, it
> >> is using
> >> the standalone glue (-DXPCOM_GLUE) for components, which is not
> >> recommended.
> >> See http://developer.mozilla.org/en/docs/XPCOM_Glue

_________________________________________________________________
One and only Ash. Find out all about her. Only on MSN Search
http://server1.msn.co.in/profile/aishwarya.asp

Keren Dong

unread,
Oct 11, 2006, 3:15:26 AM10/11/06
to dev-tec...@lists.mozilla.org
Many thanks:)
I finally get the code compiled and work by using the firefox source
too.
It is just a nightmare that using XPCOM on mac...

Now my steps are:
1. First get the firefox source and compile it;
2. Make your own source like the one in the xpcom/sample directory
under the firefox source, and you can get an .xpt and .dylib as a
result;
3. Put the .xpt and .dylib got from last step into Firefox.app/
Contents/MacOS/components directory, where Firefox.app is the result
of compiling the firefox source;
4. Then delete compreg.dat and xpti.dat in the ~/Library/Application
Support/Firefox/Preference/xx.default/component directory (the
xx.default should be replaced by yours);
5. After all the things above have been done, run the Firefox.app to
test your component...
Good luck.

Note:
1. The gecko-sdk on the official web is out of date I think, do not
use it.
2. Darwin ports also can not work, for it misses the libxpcomglue.a
after install.
3. The final result made by using the above steps can not work with
the official release firefox, I do not know why.

Unfortunately I have to work on a bsd at last...What a big mess the
mozilla on the OSes except linux and windows!

> _______________________________________________
> dev-tech-xpcom mailing list
> dev-tec...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-xpcom

--
Best regards,
Keren Dong

Institue of Software, Chinese Academy of Sciences
MSN/Gtalk: drago...@gmail.com
AIM: dragonballs1983


0 new messages