无法在Windows 8上获得在Cygwin上编译的基本C ++程序

时间:2013-02-18 06:39:21

标签: c++ windows g++ cygwin

我是Cygwin,Windows和C ++的新手,所以请耐心等待。

这是C ++程序(try.cpp)我试图使用Cygwin编译。

#include<iostream>
using namepsace std;

int main(void) {
        cout<<"Trying out CPP"<<endl;
        return 0;
}

这是我正在使用的Cygwin版本(在cygwin终端上使用uname -r获得):1.7.17(0.262/5/3)

这是我用来编译程序的命令:     g++ try.cpp

以下是我得到的错误:

$ g++ try.cpp
try.cpp:2: error: expected nested-name-specifier before "namepsace"
try.cpp:2: error: `namepsace' has not been declared
try.cpp:2: error: expected `;' before "std"
try.cpp:2: error: expected constructor, destructor, or type conversion before ';' token
try.cpp: In function `int main()':
try.cpp:5: error: `cout' undeclared (first use this function)
try.cpp:5: error: (Each undeclared identifier is reported only once for each function it appears in.)
try.cpp:5: error: `endl' undeclared (first use this function)

FWIW,这是我做g++ -v时得到的结果(我猜想计算机上安装的g ++版本)“

Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /managed/gcc-build/final-v3-bootstrap/gcc-3.4.4-999/configure --verbose --program-suffix=-3 --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,pascal,java,objc --enable-nls --without-included-gettext --enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: posix
gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)

我做错了什么?

1 个答案:

答案 0 :(得分:3)

您拼错/错误输入namespacenamepsace