简体   繁体   English

没有C运行时库依赖项但具有malloc的C ++ Win32,免费atd

[英]C++ Win32 without C Runtime library dependency but with malloc, free atd

I want to reduce size of my win32 applications programmed in MS Visual Studio C++ and I also want to have guaranteed compatibility on all Windows version (XP and upper without Visual C++ Redistributable Package). 我想减小在MS Visual Studio C ++中编程的win32应用程序的大小,并且我还希望在所有Windows版本(没有Visual C ++ Redistributable Package的XP和更高版本)上都具有兼容性。 I used /MT and /NODEFAULTLIB parameter to reduce file size and get rid of C Run-Time library. 我使用/MT/NODEFAULTLIB参数来减小文件大小并摆脱C运行时库。 But I lost access to functions like malloc, free, strcat, strstr, etc... What is the best approach to bypass this problem? 但是我无法使用malloc,free,strcat,strstr等功能。绕过此问题的最佳方法是什么?

I'm thinking about this alternatives: 我正在考虑以下替代方案:

  1. Use LoadLibrary("msvcrt.dll") and GetProcAddress() to dynamic load pointer to this functions from standard windows library 使用LoadLibrary(“ msvcrt.dll”)和GetProcAddress()从标准Windows库动态加载指向此函数的指针
  2. Program this function by myself for example replace malloc with VirtualAlloc(), free with VirtualFree() etc.. 我自己编写此函数,例如用VirtualAlloc()替换malloc,用VirtualFree()释放free等。

Or is it some other solution for my problem? 还是针对我的问题的其他解决方案? Thank you 谢谢

I'll probably never understand why people want to do that (PCs are not exactly embedded platforms with all their size issues), but there's basically three options: 我可能永远也不会明白人们为什么要这么做(PC并非完全具有所有尺寸问题的嵌入式平台),但是基本上有三种选择:

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

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