简体   繁体   English

Visual Studio 2015:在没有运行时库的情况下编译C / C ++

[英]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? 有没有一种方法可以在不使用任何运行时库的情况下使用Visual Studio 2015编译C / C ++?

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 C / C ++上有选项 - >代码生成 - >运行时库
but I want an option that says "none". 但我想要一个说“无”的选项。

I'm aware of loosing a lot of features that are in the CRT. 我知道丢失了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 . 要在没有C-Runtime Library(CRT)的情况下编译应用程序,请使用/MT/NODEFAULTLIB链接器选项,并在Linker -> Advanced -> Entry Point重新定义入口点,以在代码中定义函数,例如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. 如果没有C-runtime库,则不允许使用它的函数,如mallocfreememset等。您应该自己实现所有使用过的CRT函数。 Eg you can replace usage of malloc by VirtualAlloc() and free by VirtualFree() . 例如,您可以通过VirtualAlloc()替换malloc的使用,并通过VirtualFree() free替换。

To check that C-runtime is not linked to your application use Dependency Walker . 要检查C-runtime是否未链接到您的应用程序,请使用Dependency Walker

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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