【发布时间】:2009-03-06 22:46:22
【问题描述】:
我在 Windows XP 上用 C++ 运行一个简单的 Hello-world 程序时遇到问题。我在这里写了一个帖子:
在我陈述问题的地方,我收到了许多有用的回复,这解决了一些问题。但是,我仍然无法运行我的 hello-world 程序。请看一下帖子,我已经在其中包含了该程序。我的一个朋友能够在他的机器上毫无问题地运行这个程序。所以,问题应该出在我的系统或库或其他东西上,但我不知道是什么。在我的帖子的“已编辑”部分,我已经包含了我收到的错误消息。
当我尝试像这样编译程序时收到以下信息:
g++ hello.cpp
来自 cygwin shell:
当我尝试 g++ hello.cpp 时,我得到:
hello.cpp:1: parse error before character 0357
hello.cpp: In function 'int main()':
hello.cpp:'cout' undeclared (first use this function)
hello.cpp: (Each undeclared identifier is reported only once
hello.cpp: for each function it appears in.)
hello.cpp: 'endl' undeclared (first use this function)
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
这是我尝试从 DOS 命令提示符编译程序(再次使用 g++ hello.cpp)时得到的结果:
当我尝试 g++ hello.cpp 时,我得到:
hello.cpp:1: parse error before character 0357
hello.cpp: In function 'int main()':
hello.cpp:'cout' undeclared (first use this function)
hello.cpp: (Each undeclared identifier is reported only once
hello.cpp: for each function it appears in.)
hello.cpp: 'endl' undeclared (first use this function)
【问题讨论】: