0

What I have done so far:

Platform: Windows 7 (64 bit)

Installed GCC following this method

Downloaded Armadillo (armadillo-6.400.3.tar.gz) from link

Extracted Armadillo and put the source codes in the include folder.

creating main.cpp :

#include <armadillo>

int main()
{
    return 0;
}

compiling in windows cmd terminal:

g++ main.cpp -std=c++11

The compiler error result:

D:\c++\test>g++ main.cpp -std=c++11
g++: unrecognized option `-std=c++11'
In file included from main.cpp:2:
C:\cygnus\cygwin-b20\H-i586-cygwin32\bin\..\lib\gcc-lib\i586-cygwin32\egcs-2.91.
57\..\..\..\..\..\include\g++\armadillo:24: sstream: No such file or directory
In file included from main.cpp:2:
C:\cygnus\cygwin-b20\H-i586-cygwin32\bin\..\lib\gcc-lib\i586-cygwin32\egcs-2.91.
57\..\..\..\..\..\include\g++\armadillo:27: limits: No such file or directory
In file included from C:\cygnus\cygwin-b20\H-i586-cygwin32\bin\..\lib\gcc-lib\i5
86-cygwin32\egcs-2.91.57\..\..\..\..\..\include\g++\armadillo:50,
                 from main.cpp:2:
C:\cygnus\cygwin-b20\H-i586-cygwin32\bin\..\lib\gcc-lib\i586-cygwin32\egcs-2.91.
57\..\..\..\..\..\include\g++\armadillo_bits/compiler_setup.hpp:173: #error "***
 Need a newer compiler ***"

Update

D:\c++\test>g++ --version
egcs-2.91.57
Mr Vahid
  • 9
  • 1
  • 3
  • try to change file name to abc.cpp and make sure that directory contains the abc.cpp file. – Polish Jan 05 '16 at 10:07
  • @Vimal, Unfortunately the same error happens – Mr Vahid Jan 05 '16 at 10:10
  • 1
    Have you checked how old your `g++` is ? The exe installer contains files from 1998. When it was created there was no C++11 in sight ... Go to http://www.cygwin.org/ and download a current version. – Marged Jan 05 '16 at 10:14
  • `g++ --version` to see it's version. It looks like you are using an old gcc that doesn't support c++11 – bolov Jan 05 '16 at 10:15
  • @Vimal, [screenshot](http://s10.postimg.org/86yynpel5/cpp.jpg) – Mr Vahid Jan 05 '16 at 10:16
  • 4
    egcs 2.91.57 is from 1998. cygwin b20 is from 1999. Install a modern [cygwin](http://cygwin.org/). (When a page says "This page was last updated on September 13, 2005", it's unlikely to be of help for C++11 development.) – molbdnilo Jan 05 '16 at 10:19
  • yep. Old compiler. Really old. – bolov Jan 05 '16 at 10:23
  • 1
    @molbdnilo, I would probably recommend MinGW or MSys2 over Cygwin as they build binaries that don't require the (GPL) Cygwin libraries. – Jan Hudec Jan 05 '16 at 10:32

2 Answers2

3
D:\c++\test>g++ --version
egcs-2.91.57

That is ancient. -std=c++11 is supported from gcc version 4.7 (somewhere earlier in the 4.x series the -std=c++0x option was introduced, but only the bits of C++11 that already existed were supported, since those were released before C++11 was finalized).

Upgrade to the latest MinGW or MinGW-w64 (a fork with some improvements and Win64 support).

You can also install via MSys2 or Cygwin. In the later case, mind the difference between gcc and mingw-gcc packages; the former builds binaries requiring cygwin1.dll, the later builds binaries using standard Microsoft runtime. MinGW and MSys2 should always use Microsoft runtime only.

Jan Hudec
  • 73,652
  • 13
  • 125
  • 172
  • Thanks, which packages of cygwin should I install? – Mr Vahid Jan 05 '16 at 10:33
  • @MrVahid, I don't remember exactly, but I believe it is called `mingw-g++` (or `mingw-gcc-g++`?) and that dependencies should pull in the rest. Or use default install of the stand-alone MinGW if you don't need all the emulated unix environment around it. – Jan Hudec Jan 05 '16 at 10:35
  • @MrVahid: I find Cygwin to be large and unwieldy. Unless you actually *want* a Posix layer, wouldn't a simple native compiler suffice? In that case I'd just go with MingW, e.g. from [STL's website](http://nuwen.net/mingw.html). – Kerrek SB Jan 05 '16 at 14:05
1

Judging by the file date and time and the output of the version command you are using an outdated compiler.

You should check if you need to stick to gcc, there are other compilers available on the Windows platform.

If you want to stick to gcc and especially cygwin (which contains many more unix like utilities) you should download the installer and choose the components needed. G++ would be one of them:

enter image description here

Marged
  • 10,577
  • 10
  • 57
  • 99