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

后端 未结 1 1816
日久生厌
日久生厌 2021-02-07 09:56

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 run

相关标签:
1条回答
  • 2021-02-07 10:44

    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.

    0 讨论(0)
提交回复
热议问题