C++11 Mingw32与c+交叉编译+;11
如何在Linux for Windows上交叉编译使用C++11功能的代码?到目前为止,我尝试了以下几点:C++11 Mingw32与c+交叉编译+;11,c++11,mingw,cross-compiling,C++11,Mingw,Cross Compiling,如何在Linux for Windows上交叉编译使用C++11功能的代码?到目前为止,我尝试了以下几点: #include <stdio.h> class foo { public: const char* getstr() { return "hello world"; } }; int main() { printf("Hello, World!\n"); foo f; f.getstr(); auto q = f.getstr()
#include <stdio.h>
class foo
{
public:
const char* getstr() { return "hello world"; }
};
int main()
{
printf("Hello, World!\n");
foo f;
f.getstr();
auto q = f.getstr();
return 0;
}
我想没问题,我只需要-std=c++11
选项:
i586-mingw32msvc-g++ cpp11_test.cpp -std=c++11
cc1plus: error: unrecognized command line option "-std=c++11"
仍然不走运,-版本输出为:
i586-mingw32msvc-g++ --version
i586-mingw32msvc-g++ (GCC) 4.2.1-sjlj (mingw32-2)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
有没有其他办法可以让这一切顺利进行?还是新版本?如果包管理器中没有新版本,我如何获得新版本?我是否必须使用主机操作系统的编译器从源代码构建一个更新的编译器?您的编译器已经过时。
版权(C)2007 Free Software Foundation,Inc.
应该告诉您,您的编译器最多只能支持非常差的C++11.Hmmm,如何获得更新的i586-mingw32msvc-g++?@paulm您的Linux发行版的软件包管理器可能会下载并安装更新的版本,确切的机制将取决于您使用的确切发行版。@paulm:您可以在以下位置为您的程序使用支持c++11的在线编译器:
i586-mingw32msvc-g++ --version
i586-mingw32msvc-g++ (GCC) 4.2.1-sjlj (mingw32-2)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.