c++ - 无法找到过程入口点

标签 c++ dll g++ mingw stdstring

<分区>

我正在尝试在 Windows 10 上使用 MinGW 编译 C++ 程序,但我不断收到以下错误(-Wall 和 -Werror 已激活):

The procedure entry point

_ZNSt7__cxx1112basic_stringlcSt11char_traitslcESalcEEC1EPKcRKS3_

could not be loaded in the dynamic link library

[path to executable].exe

我找到的其他类似的解决方案引用了外部 DLL,而不是可执行文件本身。

我是 C# 专家,这对我来说很陌生,所以如果这是一个非常简单的链接错误或类似问题,请原谅我。

一切都在一个文件中(因为它将由在线自动评委评分):

#include <iostream>
#include <string>

enum Months { January, February, March, April, May, June, July, August, September, October, November, December };

std::string monthNames[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
int monthLengths[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

int main(int argc, char const *argv[]);
bool isLeapYear(int year);
int daysInMonth(Months month, int year);

int main(int argc, char const *argv[])
{
    std::cout << "Leap years:" << std::endl;
    for (size_t i = 0; i < sizeof(monthNames)/sizeof(*monthNames); ++i)
    {
        std::cout << monthNames[i] << ": " << daysInMonth(static_cast<Months>(i), 2000) << std::endl;
    }

    std::cout << "Non-leap years:" << std::endl;
    for (size_t i = 0; i < sizeof(monthNames)/sizeof(*monthNames); ++i)
    {
        std::cout << monthNames[i] << ": " << daysInMonth(static_cast<Months>(i), 1999) << std::endl;
    }

    std::cin.ignore();

    return 0;
}

bool isLeapYear(int year)
{
    return ((year & 3) == 0 && ((year % 25) != 0 || (year & 15) == 0));
}

int daysInMonth(Months month, int year)
{
    if (isLeapYear(year) && month == February)
    {
        return 29;
    }

    return monthLengths[month];
}

最佳答案

您需要包含字符串标题才能使用字符串。

#include <string>

关于c++ - 无法找到过程入口点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31777831/

相关文章:

C++: asm 破坏列表

C++ 程序在第一次尝试时给出垃圾,但如果它捕获异常并重试则给出正确的值

c++ - 在C++中读取.txt文件

c++ - 注册和使用 64 位 C++ 编写的 ATL 动态库时遇到问题

c# - 从 C# 解决方案调试 C++ 解决方案

c++ - gc/c++ 在编译中省略 main,在单独的文件中提供 main

compiler-errors - OrangePi Armbian ogles_gpgpu

c++、msxml 和智能指针

c++ - 使用 COLLADA DOM 将 COLLADA 文档输出为字符串

Java:util_USBUIRT.dll:找不到依赖库