How do you pack a visual studio c++ project for release?
Asked Answered
A

6

38

I'm wondering how to make a release build that includes all necessary DLL files into the .exe so the program can be run on a non-development machine without having to install the Microsoft redistributable on the target machine.

Without doing this you get the error message that the application configuration is not correct and to reinstall.

Alyse answered 6/8, 2008 at 9:49 Comment(1)
Just use a Setup Wizard like Inno Setup. Inno Setup in particular is really easy to use if all you need is to pack a bunch of files.Aubrette
U
18
  1. Choose Project -> Properties
  2. Select Configuration -> General
  3. In the box for how you should link MFC, choose to statically link it.
  4. Choose Linker -> Input. Under Additional Dependencies, add any libraries you need your app to statically link in.
Unasked answered 13/8, 2008 at 18:10 Comment(3)
I could be missing something (I'm nothing of an expert) but after following your steps I still have to package all dll's in the exe folder. Wasn't it OP's intention to have everything packaged into the exe file?Troop
@BruceConnor. Linking libraries statically includes them into the executable file. The opposite is called dynamical linking which would let the executable look for dlls (= dunamic link library) at startup.Overpass
I followed steps exactly but like @Troop I still have to add all .dlls to exe folder.Forefather
B
10

You need to set the run-time library (Under C/C++ -> Code Generation) for ALL projects to static linkage, which correlates to the following default building configurations:

  • Multithreaded Debug/Release
  • Singlethreaded Debug/Release

As opposed to the "DLL" versions of those libraries.

Even if you do that, depending on the libraries you're using, you might have to install a Merge Module/framework/etc. It depends on whether static LIB versions of your dependencies are available.

Biondo answered 7/8, 2008 at 21:11 Comment(0)
P
4

Be aware that Microsoft do not recommend that you static link the runtime into your project, as this prevents it from being serviced by windows update to fix critical security bugs. There are also potential problems if you are passing memory between your main .exe and .dll files as if each of these static links the runtime you can end up with malloc/free mismatch problems.

You can include the DLLs with the executable, without compiling them into the .exe and without running the redist tool - this is what I do and it seems to work fine.

The only fly in the ointment is that you need to include the files twice if you're distributing for a wide range of Windows versions - newer OSs need the files in manifest-defined directories, and older ones want all the files in the program directory.

Perpendicular answered 9/9, 2008 at 11:41 Comment(0)
H
0

You'd be looking to static link (as opposed to dynamically link)

I'm not sure how many of the MS redistributables statically link in.

Hemostat answered 6/8, 2008 at 12:10 Comment(0)
C
0

If you are looking to find out which dll's your target machine is missing then use depends.exe which used to come with MSDev, but can also be found here. Testing this on a few target machines should tell you which dll's you need to package with your application.

Craniometry answered 7/8, 2008 at 6:40 Comment(0)
M
0

You should use a static link and add all libraries you need under additional dependencies.

Monospermous answered 5/3, 2020 at 19:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.