Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to build a DLL in C++ that has no dependencies?

Tags:

c++

dll

I would like to deploy a very simple DLL with my C# application, but any DLL that I build in Visual Studio 2008 seems to have a dependency on "Microsoft.VC90.CRT". Is it possible to build a DLL using VS2008 without this dependency? How can I tell what is causing the dependency?

like image 448
Jon Tackabury Avatar asked Dec 04 '08 17:12

Jon Tackabury


People also ask

Do DLLs have dependencies?

When you use depends.exe, be aware that a DLL might have a dependency on another DLL or on a specific version of a DLL. You can use depends.exe on either the development computer or on a target computer. On the development computer, depends.exe reports the DLLs that are required to support an application.

What are DLL files in C?

In Windows, a dynamic-link library (DLL) is a kind of executable file that acts as a shared library of functions and resources. Dynamic linking is an operating system capability. It enables an executable to call functions or use resources stored in a separate file.


2 Answers

I'm not sure about the latest VC++ versions, but previously you could tell the linker to link with a static version of the MSVCRT runtime library instead of the dynamic (DLL) version. It's possible this option still exists.

like image 105
Greg Hewgill Avatar answered Oct 14 '22 21:10

Greg Hewgill


According to this MSDN page, static libraries are still available. Go to project properties, configuration properties, C/C++, Code generation, Runtime Library.

Select Multithreaded Debug for the debug configuration, and Multithreaded for the release config. (Not sure if the names are all the same in VS2008, but should be "somewhere around there". Can update tomorrow with VS2008-specific differences)

Also, as wbic16 suggested, use dependency walker to identify other static dependencies.

like image 41
peterchen Avatar answered Oct 14 '22 21:10

peterchen