64-bit compilation errors in Visual Studio 2005

After just having spent some hours trying to compile a C/C++ piece into a 64-bit DLL I came across with a number of error messages searching for which does not yield a lot of great results, so I thought to post them here for the benefit of the others who come across:

  1. “unresolved external symbol __security_check_cookie”: Configuration Properties->C/C++->Code Generation switch off Buffer Security Check (/GC- command line) and this error goes away
  2. “unresolved external symbol _DllMainCRTStartup” (not to be confused with __DllMainCRTStartup@): Configuration Properties->Linker->Input – make sure “Ignore All Default Libraries” is set to “no”.
  3. Could not find kernel32.lib user32.lib etc – if you search for this files in VS2005 directory you will find them in various places, but for 64-bit mode they should be in AMD64 – if they are not there, then go to setup of VS and make sure you installed 64-bit compilers and tools: you can try install recent Platform SDK from Microsoft, however even though it contains these files in correct directory they don’t appear to help compile even if you provide path to them in “Additional Library Directories” in Linker options.
  4. “module machine type ‘X86′ conflicts with target machine ‘X64′” – this message appears if you have not got correct 64-bit kernel32.lib or other similar DLLs, so that VS takes 32-bit versions and then can’t link them since they are not 64-bit. This error comes up after you think you “fixed” error #3 by giving path to place where you think correct kernel32.lib exists – solution is the same as in error #3.

Hope this will save a few hours of fruitless efforts trying to understand what the heck Visual Studio is on about when trying to compile a wee 64-bit .DLL :)

One Response to “64-bit compilation errors in Visual Studio 2005”

  1. Bo Says:

    In 1, the option should be /GS-

Leave a Reply