Google 网上论坛不再支持新的 Usenet 帖子或订阅项。历史内容仍可供查看。

How to build xpcom component on Mac OS X?

已查看 51 次
跳至第一个未读帖子

Keren Dong

未读,
2006年9月30日 03:57:172006/9/30
收件人 dev-tec...@lists.mozilla.org
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:

################################## Makefile
##################################
CXX = g++
CPPFLAGS += -fno-rtti \
-fno-exceptions
# -shared

# Change this to point at your Gecko SDK directory.
GECKO_SDK_PATH = /Users/dkr/Develop/mozilla/mozilla/dist/sdk

# GCC only define which allows us to not have to #include mozilla-config
# in every .cpp file. If your not using GCC remove this line and add
# #include "mozilla-config.h" to each of your .cpp files.
GECKO_CONFIG_INCLUDE = -include mozilla-config.h

GECKO_DEFINES = -DXPCOM_GLUE

GECKO_INCLUDES = -I $(GECKO_SDK_PATH)/include

GECKO_LDFLAGS = -L$(GECKO_SDK_PATH)/lib -lxpcomglue \
-lnspr4 \
-lplds4

FILES = MyComponent.cpp MyComponentModule.cpp

TARGET = MyComponent.dylib

build:
$(CXX) -Wall -Os -o $(TARGET) $(GECKO_CONFIG_INCLUDE) $
(GECKO_DEFINES) $(GECKO_INCLUDES) $(GECKO_LDFLAGS) $(CPPFLAGS) $
(CXXFLAGS) $(FILES)
chmod +x $(TARGET)
strip $(TARGET)

clean:
rm $(TARGET)

#################################### End
####################################

But I got a fail message as :
ld: Undefined symbols:
_main
__Z20NS_NewGenericModule2P12nsModuleInfoPP9nsIModule
make: *** [build] Error 1

Could anyone help me? Thanks very much.

Benjamin Smedberg

未读,
2006年10月2日 10:25:032006/10/2
收件人
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

--BDS

Nickolay Ponomarev

未读,
2006年10月2日 10:46:542006/10/2
收件人 Benjamin Smedberg、dev-tec...@lists.mozilla.org
Did you try writing to the article's author and mentioning the
problems you see with the article? People probably just don't know
there are problems with it, and there are indeed few good tutorials on
this topic.

Nickolay

Jamie Newton

未读,
2006年10月3日 17:27:572006/10/3
收件人
I've followed the instructions at
http://developer.mozilla.org/en/docs/XPCOM_Glue and no matter what I do I
still run up against this problem on MacOSX too. I can compile (and run) my
component fine on windows. I think the docs there must be just plain wrong
too.

__Z20NS_NewGenericModule2P12nsModuleInfoPP9nsIModule


"Benjamin Smedberg" <benj...@smedbergs.us> wrote in message
news:5didnVqD9MSgvLzY...@mozilla.org...

Jamie Newton

未读,
2006年10月6日 17:51:232006/10/6
收件人
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

未读,
2006年10月8日 03:43:032006/10/8
收件人 dev-tec...@lists.mozilla.org
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"...

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

Benjamin Smedberg

未读,
2006年10月8日 10:49:162006/10/8
收件人
Keren Dong wrote:
> 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"...

Don't use regxpcom (ever).

Please *do* touch Contents/MacOS/.autoreg (or delete the compreg.dat in the
profile directory); Firefox will not automatically register new components
that are put in the components directory until you do this.

--BDS

Kevin

未读,
2006年10月11日 21:56:452006/10/11
收件人
Benjamin Smedberg wrote:
> 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
>
> --BDS

The best thing anyone can do for XULRunner/XPCOM acceptance is to
provide a great example XPCOM component that WORKS with XULRunner.
Personally, after lots of problem-solving and guessing, I've given up
on writing a XPCOM component for XULRunner. The current examples just
don't work, and I can't figure out why. I'll come back to
XULRunner/XPCOM after there are some better examples that are well
documented and work.
--Kevin

0 个新帖子