Mingw32与c ++ 11交叉编译

时间:2014-04-09 19:53:09

标签: c++11 mingw cross-compiling

如何使用C ++ 11功能的代码在Linux for Windows上交叉编译?到目前为止,我尝试了以下内容:

#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;
}

无法使用以下内容构建:

i586-mingw32msvc-g++ cpp11_test.cpp 
cpp11_test.cpp: In function ‘int main()’:
cpp11_test.cpp:15: error: ISO C++ forbids declaration of ‘q’ with no type
cpp11_test.cpp:15: error: invalid conversion from ‘const char*’ to ‘int’

没问题,我想,我只需要-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.

还有其他选择让这项工作成功吗?还是新版本?如果不在包管理器中,我将如何获得新版本,我是否必须使用主机操作系统编译器从源代码构建更新的编译器?

0 个答案:

没有答案