如何创建Win32 DLL而不依赖于C运行时 [英] How do I create a Win32 DLL without a dependency on the C runtime

查看:241
本文介绍了如何创建Win32 DLL而不依赖于C运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Visual Studio 2008及其C / C ++编译器,如何创建仅依赖于其他Windows DLL的Win32 DLL,并且不依赖Microsoft C运行时?

Using Visual Studio 2008 and its C/C++ compiler, how do I create a Win32 DLL that is dependent only on other Windows DLLs, and has no dependency on the Microsoft C runtime?

我有一些C代码,我想放在一个完全计算的DLL中,几乎没有使用C库函数。

I have some C code I want to place in a DLL that is entirely computation, and makes almost no use of C library functions.

对于那些确实使用(例如memcpy),我很乐意重写代码以使用Win32 API等价物(例如CopyMemory)。

For those it does use (eg memcpy), I'm happy to rework the code to use the Win32 API equivalents (eg CopyMemory).

推荐答案

使用/ NODEFAULTLIB链接器选项,(当然)确保您在运行时没有实际的依赖关系。您还必须指定&使用/ ENTRY链接器选项为DLL定义自己的入口点,或者有自己的入口点函数与编译器/链接器所分配的名称相匹配(我忘了那是什么)。

Use the /NODEFAULTLIB linker option and (of course) make sure you have no actual dependencies on the runtime. You'll also have to specify & define your own entry point for the DLL using the /ENTRY linker option or alternatively have your own entry point function that matches the name exected by the compiler/linker (I forget what that is).

Matt Pietrek的文章从LIBCTINY开始可能会获得所需的所有信息:

Matt Pietrek's article from way back when on LIBCTINY will probably have all the information you need:

  • http://msdn.microsoft.com/en-us/library/bb985746.aspx

这篇关于如何创建Win32 DLL而不依赖于C运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆