Visual Studio 2015: compiling C / C ++ without a runtime library

Is there a way to compile C / C ++ with Visual Studio 2015 without using any runtime library?

I need to compile without a runtime library because I create my own runtime library (for my OS).

There are options in C / C ++ -> Code Generation -> Runtime Library

but I want an option that says no.

I know that I am losing a lot of functions that are in CRT.

+7
c ++ c visual-studio crt
source share
1 answer

To compile your application without the C-Runtime library (CRT), use the /MT , /NODEFAULTLIB /MT linker options and override the entry point in Linker -> Advanced -> Entry Point for the function defined in your code, for example. rawMain . Signature:

 DWORD CALLBACK rawMain(); 

Without the C-runtime library, you are not allowed to use its functions, such as malloc , free , memset , etc. You must implement all the used CRT functions yourself. For example. you can replace using malloc with VirtualAlloc() and free with VirtualFree() .

To verify that C-runtime is not associated with your application, use Dependency Walker .

+7
source share

All Articles