简体   繁体   English

执行用 C++ 编写的 .exe 的问题(使用 mingw 编译器)

[英]Issue with executing .exe written in C++ (using mingw compiler)

I am new to programming and trying to learn C++ using C++ Primer (5th ed.).我是编程新手,并尝试使用 C++ Primer(第 5 版)学习 C++。 I have written this code that is directly from the book.我已经直接从书中编写了这段代码。 The issue is when trying to execute the .exe results with this prompt popping up问题是在尝试执行 .exe 结果并弹出此提示时

The procedure entry point _ZNKSt9basic_ioslcSt11char_traitslcEEcvbEv could not be located in the dll无法在 dll 中找到过程入口点 _ZNKSt9basic_ioslcSt11char_traitslcEEcvbEv

The .cpp .cpp

#include <iostream>

main ()
{
    int sum = 0, val = 0;

    while (std::cin >> val) 
        sum += val;

    std::cout << "The sum is: " << sum << std::endl;

    return 0;
}

Take a look at the directory where your mingw compiler is installed.查看安装 mingw 编译器的目录。 Within the "bin" directory you should finde several "*.dll" files like "libwinpthread-1.dll", "ligstdc++-6.dll" and so on...在“bin”目录中,您应该找到几个“*.dll”文件,例如“libwinpthread-1.dll”、“ligstdc++-6.dll”等等...

These libraries are required to execute your application since mingw needs some platform wrapping magic (its a port of gcc for linux).这些库是执行应用程序所必需的,因为 mingw 需要一些平台包装魔法(它是用于 linux 的 gcc 端口)。

Try to copy these dll's into the same folder of where your "*.exe" is located.尝试将这些 dll 复制到“*.exe”所在的同一文件夹中。

If this does not help: The error message is a bit confusing since I would expect it to report a dll file is missing instead of a missing procedure.如果这没有帮助:错误消息有点令人困惑,因为我希望它报告缺少 dll 文件而不是缺少程序。 In this case it looks like your compiler installation is broken or as already mentioned your build environment is not correctly set up.在这种情况下,您的编译器安装似乎已损坏,或者如前所述,您的构建环境设置不正确。 Which mingw version are you using, where did you get it from?你使用的是哪个 mingw 版本,你从哪里得到的?

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

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