Search code examples
c++visual-studioassembliesexestatic-linking

how to add statically link run-time assemblies?


i am trying to run an exe file on another computer that doesn't have visual studios installed. When i try run the file i get the error : This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.

I tried searching for the answer and i lot of websites mention static link run-time assemblies

but i have no idea how to add them into my project.

(Program is in visual studios 2008 in c++ console)


Solution

  • It is hard to tell exactly what libraries are missing. Here are some ideas.

    • You are deploying a debug version. As non-development computers typically don't have debug libraries deployed (mfc*xxxd.dll & co.) your app cannot start. You should deploy the release version.
    • You app is built with newer version of C runtime or MFC which is not available on target machine. You should install Visual C++ redistributable package for your version of VS / development tools.
    • If you can't install this, you should statically link runtime/MFC libraries to your app. Depending on your version of VS, you need to go to project settings and check correct version of runtime libs (static vs dynamic)

    If still there are issues, you should check exactly which dlls are missing by using a tool like Dependency Walker on the target machine (actually this should always be the first thing you should do instead of guessing). It will show you which dlls are missing. If everything seems OK, then you are missing some delay-loaded or COM dll - this are not loaded on startup but on demand. You can use DependencyWalker to profile the startup of the app to see exactly what's missing.