Yeah, our documentation sucks :-(
Basically, xpcomglue_s.lib defines a bunch of helper classes and wrappers around the frozen XPCOM interface. xpcom.lib is the import library for that frozen interface. You could write a proper XPCOM component using nothing but xpcom.lib as the import library. However, if you copy sample code, you will undoubtably make use of stuff that is part of the glue library. So, you need to statically link that code into your component (which is what linking to xpcomglue_s.lib gives you). Now, xpcomglue.lib is a variant on xpcomglue_s.lib. If you are writing components, then you probably do not want to use xpcomglue.lib. It is really intended for embedders who are creating an application that must first locate a GRE on the host system and then load it and use it. So, it provide stubs for all of the frozen XPCOM functions. So, if you link against xpcomglue.lib, then you must not link against xpcom.lib.
There are various issues related to what I have said here if you try to use a version of the Gecko SDK from before Mozilla 1.7.5, but I won't go into those right now.
Another thing to keep in mind is that you should link your component against the version of the Gecko SDK that corresponds to the oldest version of Mozilla that you wish to support. So, if you link against the Gecko SDK from Mozilla 1.7, then your component will work with Mozilla 1.7 and above. That includes Firefox 1.0 and Thunderbird 1.0 since they are based on a branch that is very close to Mozilla 1.7, with a compatible frozen API. (The Gecko SDK from Mozilla 1.7.5 was only slightly revised to fix a couple bugs and to make it easier to use xpcomglue_s.lib as I described above.)
Make sure you define MOZILLA_STRICT_API when using the Gecko SDK. If you choose to link against xpcomglue.lib, then you must also define XPCOM_GLUE. Otherwise, that should not be defined.
-Darin
Costin Manolache wrote:
Thanks, that solves it ( also using PR_Malloc worked :-) ) !
I'm still a bit confused - could you send a short description ( or pointer to ) on what each library does ? In particular the difference between xpcomglue, xpcomglue_s and xpcom lib... Maybe some search engine will pick that up :-)
Costin
Darin Fisher wrote:
Costin,
Have you tried linking to xpcomglue_s.lib and xpcom.lib together?
-Darin
Costin Manolache wrote:
Hi,
I'm trying to compile an xpcom component using the sdk. It all works well on linux, and it also worked on win32 for the bare plugin ( i.e. most of my code commented out, just few printf ).
When I add my code - I get link errors. The problem seems to be related to NS_Alloc symbol - the linker reports that the symbol can't be found.
Using nm on the .obj: U __imp__NS_Alloc
In the sdk, I found 2 libs defining the symbol:
nm /c/gecko-sdk/lib/xpcom.lib |grep NS_Alloc 00000000 T _NS_Alloc 00000000 I __imp__NS_Alloc
nm /c/gecko-sdk/lib/xpcomglue.lib |grep NS_Alloc 00000000 T _NS_Alloc U _NS_Alloc U _NS_Alloc
I am assuming it is correct to link against xpcomglue only ( otherwise NewModule2 can't be found ), since linking against both xpcom and xpcomglue fails with duplicated symbols. However only xpcom.lib define
the __imp__NS_Alloc. If I switch and link with it - NS_Alloc is linked, but NewGenericModule2 is not.
The link message is: LINK : warning LNK4049: locally defined symbol "_NS_Alloc" imported and after linking, NS_Alloc returns allways null.
Could someone clarify how this works ? I'm new to mozilla, and I found very little on the web.
Also - regxpcom.exe and xpidl in sdk ( and most other exe ) doesn't seem to work, but if I copy xpcom.dll, nspr4.dll, plc4.dll plds4.dll from firefox and mozilla ( mozilla 1.7.3 doesn't seem to include xpcom.dll ) - I got them working. Am I doing something wrong - should I set some env variables or is there some other way to run them or install the sdk ?
( I tried sdk from 1.7.3, 1.7.5 and latest nightly )
Costin _______________________________________________ Mozilla-xpcom mailing list [email protected] http://mail.mozilla.org/listinfo/mozilla-xpcom
_______________________________________________ Mozilla-xpcom mailing list [email protected] http://mail.mozilla.org/listinfo/mozilla-xpcom
_______________________________________________ Mozilla-xpcom mailing list [email protected] http://mail.mozilla.org/listinfo/mozilla-xpcom
