问题
Is there a way of compiling C/C++ with Visual Studio 2015 without using any runtime library?
I need to compile without a runtime library because I'm creating my own runtime library (for my OS).
There are options on C/C++->Code Generation->Runtime Library
but I want an option that says "none".
I'm aware of loosing a lot of features that are in the CRT.
回答1:
To compile your app without C-Runtime Library (CRT) use /MT, /NODEFAULTLIB linker options and redefine entry point at Linker -> Advanced -> Entry Point to function defined in your code, e.g. rawMain. The signature is:
DWORD CALLBACK rawMain();
Without C-runtime library you are not allowed to use it's functions, like malloc, free, memset, etc. You should implement all the used CRT functions by yourself. E.g. you can replace usage of malloc by VirtualAlloc() and free by VirtualFree().
To check that C-runtime is not linked to your application use Dependency Walker.
来源:https://stackoverflow.com/questions/39217241/visual-studio-2015-compile-c-c-without-a-runtime-library