簡體   English   中英

無法在Windows 8上獲得在Cygwin上編譯的基本C ++程序

[英]Unable to get a basic C++ program to compile on Cygwin on Windows 8

我是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)

我究竟做錯了什么?

您拼寫錯誤/錯誤的namespacenamepsace

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM