Mapi32.lib and 64 Bit MAPI Programs


I’m in the process of updating the Outlook 2007 MAPI Samples for Outlook 2010 and ran into something that deserves some clarification. Suppose you have a 32 bit application which uses MAPI and which links in mapi32.lib. In preparation for 64 bit MAPI, you decide to try rebuilding as a 64 bit app. You install the updated MAPI headers, point your installer at them, then try building a 64 bit flavor. The 64 bit compiler might catch a few type casting errors, which you fix, then it’s time to link.

Now – if you do what I did a couple days ago, you don’t mess with the linked library settings and just let it build. And if you have the Microsoft SDK installed, it might succeed. How is this possible, when mapi32.lib is a 32 bit library?

We look at the SDK for copies of mapi32.lib:

C:\Program Files\Microsoft SDKs>dir /s mapi32.lib
 Directory of C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib
09/27/2007  03:20 PM            34,778 MAPI32.Lib
               1 File(s)         34,778 bytes

 Directory of C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\x64
09/27/2007  03:20 PM            28,478 MAPI32.Lib
               1 File(s)         28,478 bytes

This is why the link succeeded, and this is the problem I’m here to warn you about. That 64 bit build of mapi32.lib shouldn’t exist. To put it another way: The 64 bit build of mapi32.lib is bad and should be avoided! Basically, the SDK team built and shipped this library without the involvement of Office. There were a number of changes which should have been made to get it ready for 64 bit MAPI, but weren’t made. We’re still investigating if it would be possible for Office to ship a 64 bit version of this library. But for now, if you want to build a 64 bit MAPI application, you have to explicitly link to MAPI.

BTW – this isn’t a problem for MFCMAPI, which hasn’t linked with mapi32.lib for years. 🙂

Comments (11)

  1. Alex says:

    Is this problem about the mapi32.lib resolved as of today? Do we still need to explicitly link to MAPI in x64 Outlook 2010?

  2. Yes – unless/until we ship a new lib for you to link to, you'll have to explicitly link. The MFCMAPI code shows one way to do this.

  3. Sebastian says:

    Your lib is from path v6.0A from 09/27/2007. Mine here is from path v7.0A from 09/20/2009. Is that a "good" version? Does a "good" version exist by now?

  4. There never will be a "good" version.

  5. Because no development is happening on that library.

  6. jeff li says:

    Is it possible to list which MAPI functions are affected and will not work on 64 bit please? thanks!

  7. jeff li says:

    Hi, Stephen, could you give 1-2 examples of the problem or maybe just which part of MAPI is affected? Much appreciated!! afjlee@hotmail.com

  8. I don't have examples to give. Besides, if I gave them, some people would interpret them as an exhaustive list of traps they can avoid and thus get away with using the library. Explicit linking isn't that difficult – we published everything you need to do it.

  9. jeff li says:

    Thanks, Stephen!