I'm trying to compile a C++ program with MinGW on Windows 10, but I keep receiving the following error (-Wall and -Werror are activated):
The procedure entry point
_ZNSt7__cxx1112basic_stringlcSt11char_traitslcESalcEEC1EPKcRKS3_
could not be loaded in the dynamic link library
[path to executable].exe
The other solutions I found for something like that referenced an external DLL, not the executable itself.
I'm a C# guy, and this is all foreign to me, so pardon me if it's a really simple linking error or something like that.
Everything is in one file (since it's going to be graded by an online automated judge):
#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];
}
It was actually just a problem with my MinGW installation (I used a version of g++ somewhere else, and it worked like a charm).