c++ "hello world" crashing on vm

时间:2016-06-06 14:19:40

标签: c++

so my code is very simple:

PropertyGrid

thats it. i'm using visual studio 2015. when i'm building the code no errors but when i copy the exe to my win7 vm (no visual studio installed) i'm getting: the program cant start beacuse MSVCP140.dll is missing.... why? i tried to change from debug to release but same error.... why i cant execute this simple code on a win7 without visual studio installed?

2 个答案:

答案 0 :(得分:2)

您需要静态链接到C ++运行时库。该选项将在您的构建设置中提供。这会导致它们被绑定到您的可执行文件中,因此它们不需要出现在运行程序的计算机上。 (另一种方法是将运行时二进制文件与可执行文件一起分发,但这可能很麻烦)。

顺便说一下,写std::cout << "Hello World!\n";通常比写std::endl更可取。见C++: "std::endl" vs "\n"

答案 1 :(得分:2)

您的Windows 7虚拟机缺少Visual C ++运行时dll,其中包含您在hello world程序中使用的功能,例如:性病::法院。您可以从此处下载所需的c运行时dll: https://www.microsoft.com/en-us/download/details.aspx?id=48145

相关问题