简体   繁体   中英

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

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.

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, eg 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. Eg 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM