C++ 在开始使用ISOCPP.net C++;为windows构建(nuwen)

C++ 在开始使用ISOCPP.net C++;为windows构建(nuwen),c++,compiler-errors,mingw,C++,Compiler Errors,Mingw,我有一个最小的MinGW(nuwen)设置,它是为windows编译的gcc版本6.1.0 这是我的密码 #include <stdio.h> #include <string> int main (int argc, char* argv[]) { printf ("hello world\n"); std::string mystring {"my string"}; } #包括 #包括 int main(int argc,char*argv[

我有一个最小的MinGW(nuwen)设置,它是为windows编译的gcc版本6.1.0

这是我的密码

#include <stdio.h>
#include <string>

int main (int argc, char* argv[]) {
    printf ("hello world\n");

    std::string mystring {"my string"};

}
#包括
#包括
int main(int argc,char*argv[]){
printf(“hello world\n”);
std::string mystring{“我的字符串”};
}
我不断得到以下错误(除其他错误外)

C:\util\MinGW\proj>gcc main.cpp

C:\Users\gmyer\AppData\Local\Temp\ccXSjGdh.o:main.cpp:(.text+0x2e):未定义对'std::allocator::allocator()'collect2.exe的引用:错误:ld返回了1个退出状态

我所做的

  • 已检查包含目录中是否存在字符串文件 CPLUS\u INCLUDE\u PATH=C:\util\MinGW\INCLUDE;C:\util\MinGW\include\freetype2 C\u INCLUDE\u PATH=C:\util\MinGW\INCLUDE;C:\util\MinGW\include\freetype2
  • 已检查“字符串”文件中是否存在分配器

是否需要添加另一个include文件以使其工作?

您应该使用
g++
编译代码(请参阅)

还可以使用开关(
g++--std=c++11
)或更改

std::string mystring {"my string"};
进入

(是C++11特性,V14.0使用C++03作为默认模式)

std::string mystring = "my string";