c++linkerxpcomgeckosdk

Linking with XulRunner v.34 to create an XPCOM extension for Firefox


I am using the latest Gecko SDK (xulrunner-34.0.5.en-US.win32.sdk) with MSVS 2013 and I am facing serious issues with the linker (and apparently I am not the only one).

After a lot of workarounds for various issues I get these linker errors:

            Error   3   error LNK2001: unresolved external symbol "enum tag_nsresult __cdecl NS_TableDrivenQI(void *,struct nsID const &,void * *,struct QITableEntry const *)" (?NS_TableDrivenQI@@YA?AW4tag_nsresult@@PAXABUnsID@@PAPAXPBUQITableEntry@@@Z)   C:\Users\user\Desktop\sample\sample\sample\nsSample.obj sample
            Error   4   error LNK2001: unresolved external symbol "public: unsigned short const * __thiscall nsAString::BeginReading(void)const " (?BeginReading@nsAString@@QBEPBGXZ)   C:\Users\user\Desktop\sample\sample\sample\nsSample.obj sample
            Error   5   error LNK2001: unresolved external symbol "public: virtual enum tag_nsresult __thiscall mozilla::GenericModule::CanUnload(class nsIComponentManager *,bool *)" (?CanUnload@GenericModule@mozilla@@UAE?AW4tag_nsresult@@PAVnsIComponentManager@@PA_N@Z)  C:\Users\user\Desktop\sample\sample\sample\nsSampleModule.obj   sample
            Error   6   error LNK2001: unresolved external symbol "public: virtual enum tag_nsresult __thiscall mozilla::GenericModule::UnregisterSelf(class nsIComponentManager *,class nsIFile *,char const *)" (?UnregisterSelf@GenericModule@mozilla@@UAE?AW4tag_nsresult@@PAVnsIComponentManager@@PAVnsIFile@@PBD@Z)   C:\Users\user\Desktop\sample\sample\sample\nsSampleModule.obj   sample
            Error   7   error LNK2001: unresolved external symbol "public: virtual enum tag_nsresult __thiscall mozilla::GenericModule::RegisterSelf(class nsIComponentManager *,class nsIFile *,char const *,char const *)" (?RegisterSelf@GenericModule@mozilla@@UAE?AW4tag_nsresult@@PAVnsIComponentManager@@PAVnsIFile@@PBD2@Z) C:\Users\user\Desktop\sample\sample\sample\nsSampleModule.obj   sample
            Error   8   error LNK2001: unresolved external symbol "public: virtual enum tag_nsresult __thiscall mozilla::GenericModule::GetClassObject(class nsIComponentManager *,struct nsID const &,struct nsID const &,void * *)" (?GetClassObject@GenericModule@mozilla@@UAE?AW4tag_nsresult@@PAVnsIComponentManager@@ABUnsID@@1PAPAX@Z)   C:\Users\user\Desktop\sample\sample\sample\nsSampleModule.obj   sample
            Error   9   error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall mozilla::GenericModule::Release(void)" (?Release@GenericModule@mozilla@@UAEIXZ)  C:\Users\user\Desktop\sample\sample\sample\nsSampleModule.obj   sample
            Error   10  error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall mozilla::GenericModule::AddRef(void)" (?AddRef@GenericModule@mozilla@@UAEIXZ)    C:\Users\user\Desktop\sample\sample\sample\nsSampleModule.obj   sample
            Error   11  error LNK2001: unresolved external symbol "public: virtual enum tag_nsresult __thiscall mozilla::GenericModule::QueryInterface(struct nsID const &,void * *)" (?QueryInterface@GenericModule@mozilla@@UAE?AW4tag_nsresult@@ABUnsID@@PAPAX@Z)    C:\Users\user\Desktop\sample\sample\sample\nsSampleModule.obj   sample

I have added ALL the LIB files from the SDK and still nothing. I have found similar problems from other developers, but no solutions:

http://forums.mozillazine.org/viewtopic.php?f=19&t=2288909

https://bugzilla.mozilla.org/show_bug.cgi?id=682259

The last link is supposed to provide a solution, but it is not working for me (and for another user at that page).

Has anyone any hints/solutions/suggestions for this issue?

UPDATE:

After defining XP_WIN, I get only one linker error:

LNK2001: unresolved external symbol "public: unsigned short const * __thiscall nsAString::BeginReading(void)const " (?BeginReading@nsAString@@QBEPBGXZ) C:\Users\user\Desktop\sample\sample\sample\nsSample.obj sample

That seems to bring me at the same place as this guy:

https://bugzilla.mozilla.org/show_bug.cgi?id=682259#c7

UPDATE2:

This had to do with a previous problem that I had with conflicting typedefs for char16_t inside mozilla's Char16.h and MS's yvals.h:

typedef wchar_t char16_t;
vs
typedef unsigned short char16_t;

My new solution was to define the _CHAR16T to prevent MS headers typedef-ing char16_t.


Solution

  • OK. The problems were:

    1. I had to define XP_WIN.
    2. I had to define _CHAR16T to prevent MS headers typedef-ing char16_t.

    These are the libs that I have as dependencies on at the moment:

    crmf.lib
    nss3.lib
    unicharutil_external_s.lib
    mozjs.lib
    xpcomglue.lib
    xpcomglue_staticruntime.lib
    xpcomglue_staticruntime_s.lib
    xpcomglue_s.lib
    mozglue.lib
    mozalloc.lib