Question

I'm trying to link my XPCOM extension against the 1.9.3a3pre SDK and I get the following:

error LNK2001: unresolved external symbol _moz_xmalloc

So, what lib do I need to link to? The documentation doesn't say.

This is on Windows right now, but I'll need it to build on Mac and Linux (32bit/64bit) as well.

Edit: Now with bounty.

Edit: Update: Turns out FF3.7 was cancelled. So I don't have to worry about this until FF4.

Was it helpful?

Solution

define 'XPCOM_GLUE' in C++ Preprocessor Definition property. It will fix the linking error.

OTHER TIPS

I have same error, and linking to mozalloc helps for that.

Try defining MOZ_NO_MOZALLOC when compiling your extension, you will then get a DLL that uses your CRT's allocators. (Don't forget to use the NS_* allocators for XPCOM-compatible memory.)

  1. Add MOZ_NO_MOZALLOC in C++->Preprocessor->Definition property.

  2. Use xpcomglue_s_nomozalloc.lib instead of xpcomglue_s.lib in Linker->Input->Additional Dependencies

It will be OK!

reminder note: another option that can cause this even though everything else seems to be configured correctly in the project, is pointing at the wrong libs folder - such as 32 bit version for a 64 bit build.

edit v40 mozalloc.lib has changed name to mozglue.lib and has some additional methods.

edit v41 mozglue.lib has changed name to mozcrt.lib

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top