Link error when compiling XPCOM component using gecko 15

Talk about add-ons and extension development.
Post Reply
ah6511
Posts: 42
Joined: August 10th, 2006, 12:02 pm

Link error when compiling XPCOM component using gecko 15

Post by ah6511 »

Hi, I am trying to compile the sample (http://mxr.mozilla.org/mozilla-central/ ... om/sample/) XPCOM component using latest gecko SDK (15) with VS 2010. It has following error with debug build:
........................
1>xpcomglue_s.lib(nsMemory.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in nsSample.obj
1>xpcomglue_s.lib(nsClassInfoImpl.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in nsSample.obj
1>xpcomglue_s.lib(nsStringAPI.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in nsSample.obj
1>xpcomglue_s.lib(nsCOMPtr.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in nsSample.obj
1>xpcomglue_s.lib(nsISupportsImpl.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in nsSample.obj
1>xpcomglue_s.lib(nsCRTGlue.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in nsSample.obj
1>xpcomglue_s.lib(nsTArray.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in nsSample.obj
1>xpcomglue_s.lib(nsComponentManagerUtils.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in nsSample.obj
1> Creating library C:\Samples\Firefox Extension\sample-XPCOM\Debug\sample-XPCOM.lib and object C:\Samples\Firefox Extension\sample-XPCOM\Debug\sample-XPCOM.exp
1>xpcomglue_s.lib(nsStringAPI.obj) : warning LNK4217: locally defined symbol _memmove imported in function "protected: void __thiscall nsTArray_base<struct nsTArrayDefaultAllocator>::ShiftData(unsigned int,unsigned int,unsigned int,unsigned int,unsigned int)" (?ShiftData@?$nsTArray_base@UnsTArrayDefaultAllocator@@@@IAEXIIIII@Z)
1>xpcomglue_s.lib(nsCRTGlue.obj) : warning LNK4217: locally defined symbol _fclose imported in function _printf_stderr
1>xpcomglue_s.lib(nsISupportsImpl.obj) : error LNK2001: unresolved external symbol __imp__moz_xmalloc
1>xpcomglue_s.lib(nsCRTGlue.obj) : error LNK2001: unresolved external symbol __imp__moz_xmalloc
1>xpcomglue_s.lib(nsTArray.obj) : error LNK2001: unresolved external symbol __imp__moz_xmalloc
1>xpcomglue_s.lib(nsComponentManagerUtils.obj) : error LNK2001: unresolved external symbol __imp__moz_xmalloc
1>xpcomglue_s.lib(nsMemory.obj) : error LNK2019: unresolved external symbol __imp__moz_xmalloc referenced in function "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
1>xpcomglue_s.lib(nsClassInfoImpl.obj) : error LNK2001: unresolved external symbol __imp__moz_xmalloc
1>xpcomglue_s.lib(nsStringAPI.obj) : error LNK2001: unresolved external symbol __imp__moz_xmalloc
1>xpcomglue_s.lib(nsCOMPtr.obj) : error LNK2001: unresolved external symbol __imp__moz_xmalloc
1>xpcomglue_s.lib(nsISupportsImpl.obj) : error LNK2001: unresolved external symbol __imp__moz_free
1>xpcomglue_s.lib(nsCRTGlue.obj) : error LNK2001: unresolved external symbol __imp__moz_free
1>xpcomglue_s.lib(nsTArray.obj) : error LNK2001: unresolved external symbol __imp__moz_free
1>xpcomglue_s.lib(nsComponentManagerUtils.obj) : error LNK2001: unresolved external symbol __imp__moz_free
1>xpcomglue_s.lib(nsMemory.obj) : error LNK2019: unresolved external symbol __imp__moz_free referenced in function "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)
1>xpcomglue_s.lib(nsClassInfoImpl.obj) : error LNK2001: unresolved external symbol __imp__moz_free
1>xpcomglue_s.lib(nsStringAPI.obj) : error LNK2001: unresolved external symbol __imp__moz_free
1>xpcomglue_s.lib(nsCOMPtr.obj) : error LNK2001: unresolved external symbol __imp__moz_free
1>xpcomglue_s.lib(nsStringAPI.obj) : error LNK2019: unresolved external symbol __imp__moz_xrealloc referenced in function "public: static void * __cdecl nsTArrayInfallibleAllocator::Realloc(void *,unsigned int)" (?Realloc@nsTArrayInfallibleAllocator@@SAPAXPAXI@Z)
1>xpcomglue_s.lib(nsStringAPI.obj) : error LNK2019: unresolved external symbol __imp___snprintf referenced in function "public: void __thiscall nsACString::AppendInt(int,int)" (?AppendInt@nsACString@@QAEXHH@Z)
1>xpcomglue_s.lib(nsCRTGlue.obj) : error LNK2019: unresolved external symbol __imp__rand referenced in function "void __cdecl NS_MakeRandomString(char *,int)" (?NS_MakeRandomString@@YAXPADH@Z)
1>xpcomglue_s.lib(nsCRTGlue.obj) : error LNK2019: unresolved external symbol __imp__srand referenced in function "void __cdecl NS_MakeRandomString(char *,int)" (?NS_MakeRandomString@@YAXPADH@Z)
1>xpcomglue_s.lib(nsCRTGlue.obj) : error LNK2019: unresolved external symbol __imp__vfprintf referenced in function _printf_stderr
1>xpcomglue_s.lib(nsCRTGlue.obj) : error LNK2019: unresolved external symbol __imp___fdopen referenced in function _printf_stderr
1>xpcomglue_s.lib(nsCRTGlue.obj) : error LNK2019: unresolved external symbol __imp___dup referenced in function _printf_stderr
1>C:\Samples\Firefox Extension\sample-XPCOM\Debug\sample-XPCOM.dll : fatal error LNK1120: 9 unresolved externals
......................................
The release build is fine. How can I build a debug version of the component?
I have following preprocessors: MOZ_NO_MOZALLOC;XP_WIN;XP_WIN32
and link with following libs: nspr4.lib;xpcom.lib;xpcomglue_s.lib
any help will be greatly appreciated.
ggurov
Posts: 6
Joined: March 29th, 2009, 2:13 pm

Re: Link error when compiling XPCOM component using gecko 15

Post by ggurov »

I resolved this issue with changing of 'Runtime library' (in Project settings -> C/C++ -> Code Generation) from 'Multi-threaded debug (/MTd)' to 'Multi-threaded (/MT)'
(or from 'Multi-threaded debug DLL (/MDd)' to 'Multi-threaded DLL (/MD)').
caf_anto
New Member
Posts: 1
Joined: October 1st, 2012, 9:39 am

Re: Link error when compiling XPCOM component using gecko 15

Post by caf_anto »

@ggurov, Hi, I am getting the following error while compiling the nsSampleModule.cpp. I tried your suggestion, still getting this error. Can you explain me how you got this sample compiled?

Thanks
caf

Code: Select all

1>D:\CAF\Downloads\sample\nsSampleModule.cpp(133): error C3646: 'NS_IMPL_NSGETMODULE' : unknown override specifier
1>D:\CAF\Downloads\sample\nsSampleModule.cpp(133): error C2065: 'nsSampleModule' : undeclared identifier
1>D:\CAF\Downloads\sample\nsSampleModule.cpp(134): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\CAF\Downloads\sample\nsSampleModule.cpp(134): error C2072: 'NS_DECL_CLASSINFO' : initialization of a function
1>D:\CAF\Downloads\sample\nsSampleModule.cpp(134): error C2078: too many initializers
1>D:\CAF\Downloads\sample\nsSampleModule.cpp(134): error C2440: 'initializing' : cannot convert from 'int' to 'int (nsSampleImpl)'
1>          There are no conversions to function types, although there are conversions to references or pointers to functions
1>D:\CAF\Downloads\sample\nsSampleModule.cpp(134): fatal error C1004: unexpected end-of-file found
ggurov
Posts: 6
Joined: March 29th, 2009, 2:13 pm

Re: Link error when compiling XPCOM component using gecko 15

Post by ggurov »

@caf_anto

You got compiler errors, not linker ones. I don't know what is wrong with your setup, but it is not the linker settings (only). Maybe some #include is missing.
Actually I used my own project, not the mozilla sample.
ggurov
Posts: 6
Joined: March 29th, 2009, 2:13 pm

Re: Link error when compiling XPCOM component using gecko 15

Post by ggurov »

With the introduction of the new style - new major release every 2 months - mozilla guys break the compilation compatibility of our components very often. I have to make changes in my .cpp file with almost every new SDK. Some of these changes are just about #include directives (removing or changing/adding some). It can be that the sample project is outdated (or too new) against the sdk version, which you use.
Post Reply