0

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.

user2173353
  • 4,316
  • 4
  • 47
  • 79
  • Did you compiled the xulrunner sdk? – João Augusto Dec 05 '14 at 10:06
  • @JoãoAugusto No, I got it pre-compiled from Mozilla. I don't know if compiling it myself could solve some issues... Could it? – user2173353 Dec 05 '14 at 10:07
  • 1
    I believe the "official" sdk is build with vc10, and you are using vc12, you should use the same compiler for your project. – João Augusto Dec 05 '14 at 10:11
  • @JoãoAugusto I have switched the platform toolset to `v100` in the configuration of my project. I thought that would be enough to solve the problems, isn't it? – user2173353 Dec 05 '14 at 10:13
  • you added the path to the "lib" and "sdk\lib" folders and added to the input nspr4.lib, xul.lib and xpcomglue_s_nomozalloc.lib? – João Augusto Dec 05 '14 at 10:17
  • @JoãoAugusto I have added the LIB files that you mention, but not the `nspr4.lib`. There is no such file in the SDK. Also, I have added the two lib directories (although they seem to contain the same files - I am not sure if I actually need both of them). – user2173353 Dec 05 '14 at 10:23
  • I compiled the 34 sdk, and in my project the xpcomglue_s_nomozalloc.lib requires the nspr4.lib, maybe you need to link with other xpcomglue. – João Augusto Dec 05 '14 at 10:49

1 Answers1

0

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
user2173353
  • 4,316
  • 4
  • 47
  • 79
  • FYI: Binary XPCOM and NPAPI still work in Firefox, but they are both on the way out. The recommended way to access binary code is to use JS ctypes: https://developer.mozilla.org/en-US/docs/Mozilla/js-ctypes. – user2173353 Dec 08 '14 at 16:27