3

MSVC++ provides an optimization for programmers that want to deploy only a single executable file. You can build with /MT to link the C++ runtime library and the standard C++ library into the EXE; or /MD to call C++ runtime libraries (.DLL files).

But for your own code, or third party DLLs, is it possible to generate only a single executable file?

Suppose project PrjA uses PrjB; now, PrjB only generates dynamic library PrjB.dll, not static library PrjB.lib. It there a way to configure them so that PrjA could generate PrjA.exe, which embedded PrjB.dll inside, so that only 1 file need be deployed?

Note: the constraint iss that only PrjB.DLL is provided, no static library prjB.LIB. This question is different from C++ How to compile dll in a .exe .

MSVC /MD, /MT config using C++ Runtime Library:

  • /MD Causes the application to use the multithread-specific and DLL-specific version of the run-time library.

  • /MT Causes the application to use the multithread, static version of the run-time library.

9
  • It there a way to configure them to acheive similar effect as /MD, /MDd, /MT, /MTd? Please elaborate. It's not clear to me what you did not understand after reading the documentation for those flags. Commented Nov 7, 2016 at 5:08
  • Looks like question is "how to statically link all my projects into single executable". No idea what runtime library settings has to do with that, but to link your projects statically you need to change type of your projects from "dynamic library" to "static library". Commented Nov 7, 2016 at 6:18
  • Well, make ProjB generate .lib then. /MD / /MT switches don't make .dll files go into .exe, they just select between 2 versions of the same library - one compiled as .dll and one compiled as .lib. If you really cannot make .lib and you really need single .exe then there are some tools that can "bundle" application into single exe post factum - see other question for more details. Commented Nov 7, 2016 at 7:23
  • Possible duplicate of C++ How to compile dll in a .exe Commented Nov 7, 2016 at 7:24
  • @AndreyTurkin I understand compiling prjB as .LIB is a solution, but am looking for a solution if only dynamic library prjB.DLL is available. Commented Nov 7, 2016 at 7:27

1 Answer 1

0

As mentioned on several other SO answers, there are external tools available for this task. BoxedApp is highly regarded among them (but paid).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.