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.
The C runtime Library (CRT) is the part of the C++ Standard Library that incorporates the ISO C standard library. The Visual C++ libraries that implement the CRT support native code development, and both mixed native and managed code. All versions of the CRT support multi-threaded development.
You can use devenv.exe. Use cl.exe directly (this is the c/c++ compiler and linker. Microsoft offer a make tool (similar to the unix one) called NMake.
MSVCRT vs UCRT These are two variants of the C standard library on Microsoft Windows. MSVCRT (Microsoft Visual C++ Runtime) is available by default on all Microsoft Windows versions, but due to backwards compatibility issues is stuck in the past, not C99 compatible and is missing some features.
Open your C++ code file in Text Editor, then use shortcut Ctrl+Alt+N , or press F1 and then select/type Run Code , or right click the Text Editor and then click Run Code in context menu, the code will be compiled and run, and the output will be shown in the Output Window.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With