Building plug-ins without Microsoft Visual C Run-Time (MSVCRT) dependency

From NSIS Wiki

This applies to Visual Studio 2008/2010.

  1. Linker -> Input -> Ignore All Default Libraries
    Set to Yes. Removes linkage to CRT (but does not remove dependency; see 2).
  2. Linker -> Manifest File -> Generate Manifest
    Set to Disabled otherwise your DLL will have a run time error if the required Microsoft Visual C Run Time library isn't installed (even though you're not using it).
  3. Linker -> Advanced -> Entry Point
    Enter "DllMain".
  4. C/C++ -> Code Generation -> Buffer Security Check
    Set to No if you get "unresolved external symbol __security_cookie" link errors.
  5. C/C++ -> Optimization -> Optimization
    Set to Disabled if you get "unresolved external symbol _memset" link errors.

If you get other errors then you are using CRT functions and you need to find or write replacements. Some Windows API replacements for CRT are GlobalAlloc, GlobalFree, wsprintf, lstrcpy, lstrcpyn, lstrlen and lstrcat. NSIS also provides string to integer APIs myatoi and myatou.



I use only one step from this list and it helps. This one:

Linker -> Manifest File -> Generate Manifest : to Disabled (or to No in VS 2008)

This helped me a lot. Also I changed:

C/C++ -> Code Generation -> Runtime Library to Multi-threaded (/MT) (or Multi-threaded Debug (/MTd) for _DEBUG configurations)


You can also try other steps but when I tried them I got a lot of linker errors. It is very project-specific!

--Slappy 13:40, 8 June 2011 (UTC)

Personal tools
donate
ads