简体   繁体   English

如何通过命令提示符运行 DirectX 游戏

[英]How to run a DirectX Game through Command Prompt

I have a program for DirectX, written in C++.我有一个 DirectX 程序,用 C++ 编写。 I have compiled it through Visual Studio, but I want to run that program through the Command Prompt.我已经通过 Visual Studio 编译了它,但我想通过命令提示符运行该程序。 I tried to run a Sample Direct3D Game from the Command Prompt just to be sure, but it didn't work either.为了确定,我尝试从命令提示符运行示例 Direct3D 游戏,但它也不起作用。 This Game works fine when I build it from Visual Studio 19 or Visual Studio 17, but I am not able to run it from the Command Prompt.当我从 Visual Studio 19 或 Visual Studio 17 构建此游戏时,它运行良好,但我无法从命令提示符运行它。 Everytime I do, a window pops up with the following message.每次我这样做时,都会弹出一个 window 并显示以下消息。

The code execution cannot proceed because MSVCP140D_APP.dll was not found.代码执行无法继续,因为未找到MSVCP140D_APP.dll Reinstalling the program may fix this problem.重新安装程序可能会解决此问题。

The same message is displayed about vccorlib140d_app.Dll , CONCRT140D_APP.dll , and VCRUNTIME140D_APP.dll .关于vccorlib140d_app.DllCONCRT140D_APP.dllVCRUNTIME140D_APP.dll显示相同的消息。 However, I face no such issues when running the same program through Visual Studio.但是,通过 Visual Studio 运行相同的程序时,我没有遇到这样的问题。 I've tried almost everything that I could find about this issue, but I couldn't solve it.我已经尝试了几乎所有我能找到的关于这个问题的方法,但我无法解决它。 The .exe file that I tried to run, is in the path: ..Direct3D_game_sample\cpp\x64\Debug\Simple3DGameDX我尝试运行的.exe文件位于路径中: ..Direct3D_game_sample\cpp\x64\Debug\Simple3DGameDX

I also tried running a simple OpenCV program written in C++ to read and display a sample video file, but couldn't do so either.我还尝试运行用 C++ 编写的简单 OpenCV 程序来读取和显示示例视频文件,但也无法这样做。 It runs perfectly through Visual Studio, but not through the Command Prompt.它可以通过 Visual Studio 完美运行,但不能通过命令提示符运行。 The OpenCV program returns the following errors. OpenCV 程序返回以下错误。

warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:940)
warning: vtest.avi (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:941)
OpenCV(3.4.9) Error: Bad argument (CAP_IMAGES: cannot find starting number (in the name of file): vtest.avi) in cv::icvExtractPattern, file C:\build\3_4_winpack-build-win64-vc15\opencv\modules\videoio\src\cap_images.cpp, line 246
[ERROR:0] VIDEOIO(cvCreateFileCapture_Images(filename.c_str())): raised OpenCV exception:
OpenCV(3.4.9) C:\build\3_4_winpack-build-win64-vc15\opencv\modules\videoio\src\cap_images.cpp:246: error: (-5:Bad argument) CAP_IMAGES:cannot find starting number (in the name of file): vtest.avi in function 'cv::icvExtractPattern'

PS: I'm running Windows 10 on my machine and the Sample DirectX Game App uses DirectX 11. PS:我在我的机器上运行 Windows 10 并且示例 DirectX 游戏应用程序使用 DirectX 11。

Thanks in advance提前致谢

Since your program is using the MSVCP140D_APP.dll version of the CRT, that means you built a Universal Windows Platform app (ie a UWP app ).由于您的程序使用的是 CRT 的MSVCP140D_APP.dll版本,这意味着您构建了通用 Windows 平台应用程序(即UWP 应用程序)。 You can't run such an application as a Win32 application from the command-line and have it work.您不能从命令行运行像 Win32 应用程序这样的应用程序并让它工作。 All the samples on the Windows-universal-samples GitHub are UWP apps. Windows-universal-samples GitHub 上的所有示例都是 UWP 应用程序。

You can use Powershell Commands to install and launch an appx package built from Visual Studio.您可以使用 Powershell 命令安装和启动从 Visual Studio 构建的 appx package。 See Microsoft Docs .请参阅Microsoft 文档

If what you want is a Win32 desktop application, then you need to build a different program.如果你想要的是一个 Win32 桌面应用程序,那么你需要构建一个不同的程序。 See directx-vs-templates for Win32 VS templates in the style of the "UWP" templates.请参阅“UWP”模板样式的 Win32 VS 模板的directx-vs- templates。

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

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