Click here to Skip to main content
13,200,202 members (64,347 online)
Click here to Skip to main content
Add your own
alternative version


27 bookmarked
Posted 9 Dec 2014

Visual C++: How to Create Standalone Win32 Application Not Requiring Visual C++ Runtime

, 9 Dec 2014
Rate this:
Please Sign up or sign in to vote.
How to statically link a Win32 Project with Visual C++ libraries (m***.dll)

The Problem

You may think that your Win32 project created in Visual C++ without MFC, does not require on target machine anything other than native WinAPI dlls.

But it's wrong!!!

You will see it if you will try to run the project, the creation of the Visual C++ 2010, on a freshly installed Windows:

If you will open your EXE in DependencyWalker, you will see it requires one or few DLLs but Win32 DLLs (user32, kernel32, etc)!

What can we do to make the project standalone?

  1. We can put all of the required DLLs to folder with EXE or to C:\Windows\system32\ path.
  2. We can install onto target machine a Visual C++ Redistributable with the same version as your Visual Studio and with the same bit count (x86 or x64) as your EXE.
  3. We can statically link these DLLs into your EXE - and get 100% standalone executable!

Remark: Information bellow applies to VC++ 2008 Express, but must work In other versions, too.

Statically Linking - Way 1

  1. First, go to Project -> Properties menu.
  2. Go to Configuration Properties -> C/C++ -> Code Generation.
  3. Set Runtime library property to Multi-threaded (/MT) or Multi-threaded Debug (/MTd).
  4. Build and debug it!

Statically Linking - Way 2

  1. First, go to Project -> Properties menu.
  2. Go to Configuration Properties -> Linker -> Command Line. Copy all lib names to the clipboard:

  3. Go to Configuration Properties -> General. Set Use of MFC property to Use MFC in a Static Library.
  4. Go back to linker command line.

    You will not see these libs in linker command line! It's wrong because these DLLs are needed to run your app if it uses Win32 API. To correct it, add them to Additional options:

  5. Build and debug it!


Now your EXE weighs a few hundred KBs more than before, but, it is fully standalone!


Unfortunately, you can use static linking only for VC++ Redist and other unmanaged libs, but can't do it with managed libs, can't create CLR project not requiring .NET. Because .NET isn't just library kit, it's also interpreter-like compiler that runs your application and runs standard .NET DLLs (system.dll, etc.), it's needed to be installed on PC.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

You may also be interested in...

Comments and Discussions

QuestionIt worked, thank you Pin
José Roberto Araújo Júnior9-Jul-16 10:50
memberJosé Roberto Araújo Júnior9-Jul-16 10:50 
GeneralMy vote of 1 Pin
Bartlomiej Filipek12-Dec-14 1:55
memberBartlomiej Filipek12-Dec-14 1:55 
GeneralRe: My vote of 1 Pin
Emiliarge12-Dec-14 2:59
professionalEmiliarge12-Dec-14 2:59 
GeneralMy vote of 1 Pin
Ben Ratzlaff11-Dec-14 10:19
memberBen Ratzlaff11-Dec-14 10:19 
GeneralRe: My vote of 1 Pin
Jamming111-Dec-14 10:43
memberJamming111-Dec-14 10:43 
GeneralMy vote of 1 Pin
Jamming110-Dec-14 6:18
memberJamming110-Dec-14 6:18 
QuestionIt's simple, why complicate things!!! Pin
Jamming110-Dec-14 4:53
memberJamming110-Dec-14 4:53 
AnswerRe: It's simple, why complicate things!!! Pin
Emiliarge10-Dec-14 13:02
professionalEmiliarge10-Dec-14 13:02 
GeneralRe: It's simple, why complicate things!!! Pin
David A. Gray12-Dec-14 17:11
memberDavid A. Gray12-Dec-14 17:11 
QuestionOther / preferred(?) way Pin
_GyB_10-Dec-14 3:19
member_GyB_10-Dec-14 3:19 
QuestionNow your EXE weighs a few hundred KBs more than before Pin
Kochise10-Dec-14 2:54
memberKochise10-Dec-14 2:54 
AnswerRe: Now your EXE weighs a few hundred KBs more than before Pin
Emiliarge10-Dec-14 3:52
memberEmiliarge10-Dec-14 3:52 
GeneralRe: Now your EXE weighs a few hundred KBs more than before Pin
Kochise29-Dec-14 1:33
memberKochise29-Dec-14 1:33 
GeneralRe: Now your EXE weighs a few hundred KBs more than before Pin
Emiliarge29-Dec-14 5:59
professionalEmiliarge29-Dec-14 5:59 
GeneralRe: Now your EXE weighs a few hundred KBs more than before Pin
Kochise16-Jan-15 2:09
memberKochise16-Jan-15 2:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171020.1 | Last Updated 10 Dec 2014
Article Copyright 2014 by Emiliarge
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid