简体   繁体   English

CPP文件运行,但编译为exe时不起作用

[英]CPP file runs, but doesn't work when compiled to exe

I have created a cpp file using Microsoft Visual Studio 2010 and Allegro. 我已经使用Microsoft Visual Studio 2010和Allegro创建了一个cpp文件。 It runs perfectly fine in the Visual Studio interface, but when I compile it into an exe, it says: 它在Visual Studio界面中运行得很好,但是当我将其编译为exe时,它表示:

"The program can't start because allegro-5.0.10-monolith-md-debug.dll is missing from your computer. Try reinstalling the program to fix this problem." “该程序无法启动,因为您的计算机缺少allegro-5.0.10-monolith-md-debug.dll。请尝试重新安装该程序以解决此问题。”

I am running the exe on the same computer I used to write the code and debug it, so it shouldn't be the fault of a missing dll. 我在用于编写代码并对其进行调试的同一台计算机上运行exe,因此这不应是缺少dll的问题。 Should it? 应该是? That doesn't make sense to me.... I have compiled other exes before, and they do run on other computers, and the Allegro one works just fine while it's a cpp file, but when the Allegro file is run as an exe, it says I don't have the monolith thing. 这对我来说没有任何意义。...我之前已经编译过其他exe,并且它们确实可以在其他计算机上运行,​​而Allegro可以在cpp文件中正常运行,但是当Allegro文件作为exe运行时,它说我没有整体的东西。

Why is the file failing as an exe, but not a cpp? 为什么文件无法作为exe而不是cpp失败?

This is what worked for me: 这对我有用:

When in Configuration Properties -> Debugging - Add PATH=c:\\allegro\\bin;%PATH% to the Environment Variable. 在配置属性->调试中时-将PATH=c:\\allegro\\bin;%PATH%到环境变量中。

I had the exact same error, the program was telling me that it couldn't find the monolith DLL file. 我遇到了完全相同的错误,程序告诉我找不到完整的DLL文件。 What I had noticed is instead of PATH=c:\\allegro\\bin;%PATH% I had put PATH=c:\\allegro\\bin:%PATH% . 我注意到的不是PATH=c:\\allegro\\bin;%PATH%而是我放入PATH=c:\\allegro\\bin:%PATH% The difference is not easy to spot. 区别不容易发现。

I put a : instead of a ; 我放:而不是; between bin and %PATH% 在bin和%PATH%之间

it was an easy mistake, however it caused me about 3 hours of heartache to fix. 这是一个简单的错误,但是却使我大约3个小时的心痛得以解决。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM