简体   繁体   English

当我在另一台计算机上执行(在计算机上编译的).exe时,出现此错误

[英]When I execute an .exe (compiled on my machine) on another computer it give me this error

It's my first time using Visual Studio 2017. I built a simple program in C++ on my PC. 这是我第一次使用Visual Studio2017。我在PC上用C ++构建了一个简单程序。 I was curious to see if my program works on another PC. 我很好奇我的程序是否可以在另一台PC上运行。 I tried to execute the .exe on the other computer and it gave me this kind of error: 我试图在另一台计算机上执行.exe ,它给了我这种错误:

vs(some letters and numbers).dll is missing. vs(某些字母和数字).dll丢失。

I assume that the .dll in question is part of Visual Studio. 我假设所讨论的.dll是Visual Studio的一部分。

I tried on a third PC, and this time the cmd stops working and becomes unresponsive after I execute my .exe . 我在第三台PC上尝试过,这次cmd停止工作,并在执行.exe后变得无响应。

I also have this problem when I compile with MinGW using the g++ compile feature in the cmd . 当我使用cmd的g ++编译功能使用MinGW进行编译时,我也遇到这个问题。 When I execute the program compiled with MinGW on another PC, it gives me the same error, but this time it says something like 当我在另一台PC上执行使用MinGW编译的程序时,它给了我同样的错误,但是这次它说的是

gw...dll is missing gw ... dll遗失

Is there a way to avoid this error without installing the Visual Studio (or MinGW at this point) on any other PC I want my program to run on? 有没有一种方法可以避免此错误,而无需在我要运行程序的任何其他PC上安装Visual Studio(或此时的MinGW)?

If you're interested in the code, I can put it here, but I don't think it's the problem here because I have the same issue for every other .exe compiled on my PC. 如果您对代码感兴趣,可以将其放在此处,但我认为这不是问题所在,因为在PC上编译的所有其他.exe都存在相同的问题。

Here's a picture of the error: 这是错误的图片:

图片

In case of Visual Studio, you need to install Visual C++ Redistributable libraries or provide the libraries that are required by your application with .exe file (I am not sure if it violates license or not though). 如果是Visual Studio,则需要安装Visual C ++可再发行组件库,或者为应用程序所需的库提供.exe文件(我不确定它是否违反了许可证)。

In case of MinGW, you need to provide required DLL as well. 对于MinGW,还需要提供所需的DLL。 I guess that you need libgcc_s_dw2-1.dll and libstdc++-6.dll , but you would better check it yourself. 我猜您需要libgcc_s_dw2-1.dlllibstdc++-6.dll ,但是您最好自己检查一下。 And remember about the license. 并记住许可证。

You may use Dependency Walker to analyse dependencies of your application. 您可以使用Dependency Walker来分析应用程序的依赖关系。

UPDATE (2017-12-12): I've missed the time you posted the screenshot. 更新(2017-12-12):我错过了您发布屏幕截图的时间。 As far as I see from it the problem is that you are trying to run debug version of your executable: ucrtbased.dll is the debug version of the ucrtbase library and is only available (from what I know) from Visual Studio distribution. 据我所知,问题是您正在尝试运行可执行文件的调试版本: ucrtbased.dll是ucrtbase库的调试版本,并且只能从Visual Studio发行版中获得(据我所知)。 If you want to run your application on the computers that do not have installed Visual Studio, then you should use the Release version of your application. 如果要在尚未安装Visual Studio的计算机上运行应用程序,则应使用应用程序的发行版。

In order to understand your problem you need to understand the concept of DLL. 为了了解您的问题,您需要了解DLL的概念。 Dynamic-link library(DLL) - As described by Microsoft: 动态链接库(DLL)-如Microsoft所述:

A DLL is a library that contains code and data that can be used by more than one program at the same time. DLL是一个库,其中包含可以由多个程序同时使用的代码和数据。 For example, in Windows operating systems, the Comdlg32 DLL performs common dialog box related functions. 例如,在Windows操作系统中,Comdlg32 DLL执行常见的对话框相关功能。 Therefore, each program can use the functionality that is contained in this DLL to implement an Open dialog box. 因此,每个程序都可以使用此DLL中包含的功能来实现“打开”对话框。 This helps promote code reuse and efficient memory usage. 这有助于促进代码重用和有效的内存使用。

So to put it simply, DLL is basically a bunch of compiled code, which is being linked to your code at load (or even run-time). 简而言之,DLL基本上是一堆编译后的代码,它们在加载(甚至运行时)时链接到您的代码。 Now, of course if your system is missing the DLL, your progrem will fail to work. 现在,当然,如果您的系统缺少DLL,则您的程序将无法正常工作。 To make things even worse, DLL are sensitive to the compiler that was used. 更糟的是,DLL对使用的编译器敏感。 So each DLL might have multiple version, so you will need to right DLL. 因此,每个DLL可能都有多个版本,因此您需要正确的DLL。

Now to the problem itself, the error message are the best way to start. 现在,对于问题本身,错误消息是开始的最佳方法。 They guide you what DLL are missing, and what is their name. 它们指导您缺少哪些DLL,以及它们的名称。 For instance in your case "vs*.dll" is most likely related to Visual C++ runtime redistributable . 例如,在您的情况下,“ vs * .dll”最有可能与Visual C ++运行时可重新分发有关

Finally, please note you have another consideration to make in addition to make your own system work: Every one that will use your code might face the exact same problem. 最后,请注意,除了使自己的系统正常工作之外,还需要考虑其他事项:每个将使用您的代码的人都可能会遇到完全相同的问题。 So if you actually intend to share your .EXE with other people, you will need to understand how to guide them, or even automate their installation process. 因此,如果您实际上打算与其他人共享.EXE,则需要了解如何指导他们,甚至使其安装过程自动化。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我的堆栈加倍时,它会给我临界区错误! _ctrlvalidHeappointer - when doubling my stack it give me critical section error ! _ctrlvalidHeappointer 在另一台计算机上启动使用MinGW编译的Windows应用程序时出现库链接错误 - Library link error when starting Windows application compiled with MinGW on another computer 无法在另一台计算机上运行我的exe文件。 “应用程序请求运行时以不寻常的方式终止它”错误 - Cannot run my exe file on another computer. “Application requested the runtime to terminate it in an unusual way” error 当我在一台机器上开发EXE并在另一台机器上运行它时,为什么安装vcredist_x86.exe不会修复SideBySide错误? - Why installing vcredist_x86.exe doesn't fix SideBySide error when I develop an EXE on one machine and run it on another one? 点击时如何在PowerShell中执行my.exe - How to execute my .exe in PowerShell when clicking on it 当我在另一台机器上运行我的应用程序时缺少 DLL 文件? - missing DLL file when i run my application on another machine? 为什么我的编译器在我重载增量运算符时会出错 - why my compiler give error when i overload increment operator 当我匹配它们时,来自不同结构的两个变量给我一个编译错误 - Two variables from different structs give me a compiling error when I match them C ++:当我要输入“ q”退出时,为什么这会给我引发异常抛出错误? - C++: Why does this give me an exception thrown error when I want to enter 'q' to quit? 编译的python库可在一台计算机上运行,​​但不能在另一台计算机上运行 - compiled python library works on one computer but not on another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM