系统错误:程序无法启动,因为您的计算机中缺少MSVCP140D.DLL。尝试重新安装该程序以解决此问题

System error: The program can't start because MSVCP140D.DLL is missing from your computer. Try reinstalling the program to fix this problem

本文关键字:程序 DLL MSVCP140D 重新安装 问题 解决 启动 因为 计算机 系统错误      更新时间:2023-10-16

所以我在Visual Studio 2015中使用SFML编写了一个简单的图形蛇游戏。 它在我的主计算机上完美运行。我想我应该在我的笔记本电脑上尝试一下。运行程序时,它给了我这个错误:系统错误:程序无法启动,因为您的计算机中缺少MSVCP140D.DLL。尝试重新安装该程序以解决此问题所以我在我的计算机中搜索它并找到了它,所以我把它复制到我的笔记本电脑上,然后我再次收到另一个错误,即:应用程序错误: 应用程序无法正确启动 (0xc000007b(。单击"确定"关闭应用程序。我尝试重新安装Microsoft视觉C++可再发行组件,但它仍然不起作用。(顺便说一句,这不是代码问题,我已经正确安装了 SFML 并毫无问题地使用了它的库和垃圾箱(。你的帮助对我来说意义重大。谢谢! 这是我的代码:

// 
GraphicalLoopSnakeGame.cpp : 
Defines the entry point for 
the console application.
//
#include "stdafx.h"
#include <SFML/Graphics.hpp>
#include <time.h>
using namespace sf;
int N = 30, M = 20;
int size = 16;
int w = size*N;
int h = size*M;
int dir, num = 4;
struct Snake
{
int x, y;
}       s[100];
struct Fruit
{
int x, y;
}   f;
void Tick()
{
for (int i = num;i>0;--i)
{
s[i].x = s[i - 1].x; 
s[i].y = s[i - 1].y;
}
if (dir == 0) s[0].y += 1;
if (dir == 1) s[0].x -= 1;
if (dir == 2) s[0].x += 1;
if (dir == 3) s[0].y -= 1;
if ((s[0].x == f.x) && (s[0].y == f.y))
{
num++; f.x = rand() % N; f.y = rand() % M;
}
if (s[0].x>N) s[0].x = 0;  if (s[0].x<0) s[0].x = N;
if (s[0].y>M) s[0].y = 0;  if (s[0].y<0) s[0].y = M;
for (int i = 1;i<num;i++)
if (s[0].x == s[i].x && s[0].y == s[i].y)  num = i;
}
int main()
{
srand(time(0));
RenderWindow 
window(VideoMode(w, h), 
"Snake Game!");
Texture t1, t2, t3; 
t1.loadFromFile("images/white.png");
t2.loadFromFile("images/red.png");
t3.loadFromFile("images/green.png");
Sprite sprite1(t1);
Sprite sprite2(t2);
Sprite sprite3(t3);
Clock clock;
float timer = 0, delay = 0.12;
f.x = 10;
f.y = 10;
while (window.isOpen())
{
float time = clock.getElapsedTime().asSeconds();
clock.restart();
timer += time;
Event e;
while (window.pollEvent(e))
{
if (e.type == Event::Closed)
window.close();
}
if (Keyboard::isKeyPressed(Keyboard::Left)) dir = 1;
if (Keyboard::isKeyPressed(Keyboard::Right)) dir = 2;
if (Keyboard::isKeyPressed(Keyboard::Up)) dir = 3;
if (Keyboard::isKeyPressed(Keyboard::Down)) dir = 0;
if (timer>delay) { timer = 0; Tick(); }
////// draw  ///////
window.clear();
for (int i = 0; i<N; i++)
for (int j = 0; j<M; j++)
{
sprite1.setPosition(i*size, j*size);  window.draw(sprite1);
}
for (int i = 0;i<num;i++)
{
sprite2.setPosition(s[i].x*size, s[i].y*size);  window.draw(sprite2);
}
sprite3.setPosition(f.x*size, f.y*size);  window.draw(sprite3);
window.display();
}
return 0;
}

您正在使用调试 Visual Studio 运行时,如果要在另一台计算机上试用它,则应在发布模式下重新编译代码,并确保安装了相应的 Visual Studio 运行时可再发行组件。

如果你真的需要在另一台机器上运行调试可执行文件,你需要确保复制正确的运行时(32位或64位,取决于你编译程序的方式(,这可以C:Program Files (x86)Microsoft Visual Studio2019ProfessionalVCRedistMSVC14.24.28127debug_nonredist中找到(至少对于Visual Studio 2019,确切的路径会略有不同,具体取决于你的Visual Studio版本, 例如,Visual Studio 2015 使用C:Program Files (x86)Microsoft Visual Studio 14.0VCredistdebug_nonredist(。

就我而言,PC缺少程序的运行时支持DLL。我建议你应该从MS网站下载它,并确保没有病毒:https://www.microsoft.com/en-US/download/details.aspx?id=48145

应用程序无法正确启动 (0xc000007b(。单击"确定"关闭应用程序。首先,我建议使用依赖 walker 测试您的应用程序与其依赖项之间是否存在问题。

然后错误代码表示:0xC000007B STATUS_INVALID_IMAGE_FORMAT。我认为您尝试将 64 位 DLL 与 32 位应用程序一起使用(反之亦然(。