问题描述
使用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运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!