What lib in the gecko 1.9.3 SDK do I link against to use moz_xmalloc()?

1.1k Views Asked by At

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.

5

There are 5 best solutions below

1
On BEST ANSWER

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

5
On

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

2
On

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.)

0
On

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

0
On
  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!