Visual C++/Studio: Application configuration incorrect?

后端 未结 10 1516
执笔经年
执笔经年 2020-12-18 11:11

My C(++) program, written and compiled using Visual C(++)/Visual Studio, runs fine on my own machine, but refuses to run on another machine. The error message I get is \"Thi

相关标签:
10条回答
  • 2020-12-18 11:43

    If you write a C++ program, it links dynamically to the C Runtime Library, or CRT for short. This library contains your printf, your malloc, your strtok, etcetera. The library is contained in the file called MSVCR80.DLL. This file is not by default installed on a Windows system, hence the application cannot run.

    The solution? Either install the DLL on the target machine through VCREDIST.EXE (the Visual C++ Redistributable Package), or link to the CRT statically (plug the actual code for the used functions straight into your EXE).

    Distributing and installing VCREDIST along with a simple application is a pain in the arse, so I went for the second option: static linking. It's really easy: go to your project's properties, unfold C/C++, click Code Generation, and set the Runtime Library to one of the non-DLL options. That's all there is to it.

    0 讨论(0)
  • 2020-12-18 11:43

    First thing you must use

    #define _BIND_TO_CURRENT_VCLIBS_VERSION 1
    

    or add _BIND_TO_CURRENT_VCLIBS_VERSION=1 to the preprocessor directives.

    The problem is related to binding and the manifest types, you can find more http://www.nuonsoft.com/blog/2008/10/29/binding-to-the-most-recent-visual-studio-libraries/

    By doing this your application will run with a larger range of runtime libraries versions.

    0 讨论(0)
  • 2020-12-18 11:50

    The problem here is a missing DLL dependency, such as the CRT (C Runtime Library). A good tool for diagnosing this sort of problem is Dependency Walker (depends.exe), which you can find here:

    http://www.dependencywalker.com/

    You would run this program on the computer that generates the error message you posted, and use it to open the exe that's generating this error. Dependency Walker will quickly and graphically indicate any DLLs that are required but not available on the machine.

    0 讨论(0)
  • 2020-12-18 11:50

    Often times this error is the result of attempting to run the debug version of an application that uses .NET. Since the .NET redistributable package doesn't include the debug versions of the dlls that are installed with Visual Studio, your application will often get this error when running it on any other machine that doesn't have Visual Studio installed. If you haven't already, try building a release version of your application and see if that works.

    0 讨论(0)
  • 2020-12-18 11:55

    Chances are high that you miss the runtime libraries of Visual Studio (CRT amongst others), you can either get rid of those dependencies (link statically) or install the VC redist packages on the target computer.

    Depending on the Visual C++ version you use, you have to install different packages :

    Visual C++ 2005

    Visual C++ 2005 SP1

    Visual C++ 2008

    Warning : those packages only contain release versions of the libraries, if you want to be able to distribute debug builds of your application you'll have to take care of the required DLL yourself.

    0 讨论(0)
  • 2020-12-18 11:55

    Note also - that if you change to static runtime, you will have to do the same for MFC if your app uses MFC. Those settings are in properties->Configuration/General

    0 讨论(0)
提交回复
热议问题