Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a Win32 DLL without a dependency on the C runtime

Tags:

c++

c

dll

winapi

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?

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.

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

like image 761
John McAleely Avatar asked Aug 14 '09 18:08

John McAleely


People also ask

What is the C runtime?

The C runtime Library (CRT) is the part of the C++ Standard Library that incorporates the ISO C standard library. The Visual C++ libraries that implement the CRT support native code development, and both mixed native and managed code. All versions of the CRT support multi-threaded development.


1 Answers

You'd have to make sure none of the Win32 DLLs you use need the C runtime as well or else you back at square one. Compiling your DLL statically won't matter if one of the Win32 DLLs depends on the C runtime.

The only way I can see this working is to statically link ALL your dependent DLLs (if that is even feasible) into your DLL. This of course means you would have to recompile to take advantage of any DLL updates.

like image 136
Kelly S. French Avatar answered Oct 19 '22 10:10

Kelly S. French