这个helloworld计划有什么问题? [英] what's wrong with this helloworld program?
问题描述
当我尝试gcc以下Helloworld计划时:
#include< iostream>
int main()
{
使用命名空间std;
cout<< 你好,世界!! \ n;
返回0;
}
我收到的错误如下:
C:\Documents and Settings\benben> gcc ben.cpp
C:\ DOCUME~1 \benben\LOCALS~1 \Temp / ccojbaaa.o(。text + 0x33):ben.cpp:undefined
参考
$ b $参加`std :: cout''
C:\ DOCUME~1 \benben\LOCALS~1\Temp / ccojbaaa.o(。text + 0x38):ben.cpp:undefined
参考
$ b $生成`std :: basic_ostream< char,std :: char_traits< char> >&安培; std :: operator<<
< std
:: char_traits< char> >(std :: basic_ostream< char,std :: char_traits< char>>&,
char c
onst *)''
C:\ DOCUME~1 \benben\LOCALS~1\Temp / ccojbaaa.o(。text + 0x64):ben.cpp:undefined
参考
$ b $生成`std :: ios_base :: Init :: Init()''
C:\ DOCUME~1 \benben\LOCALS~1\Temp / ccojbaaa。 o(。text + 0x83):ben.cpp:undefined
参考
$ b $参见`std :: ios_base :: Init :: ~Init()''
发生了什么事?任何人都可以帮助我吗?
When I try to gcc the following Helloworld program:
#include <iostream>
int main()
{
using namespace std;
cout << "Hello, World!!\n";
return 0;
}
I got errors as follows:
C:\Documents and Settings\benben>gcc ben.cpp
C:\DOCUME~1\benben\LOCALS~1\Temp/ccojbaaa.o(.text+0x33):ben.cpp: undefined
refer
ence to `std::cout''
C:\DOCUME~1\benben\LOCALS~1\Temp/ccojbaaa.o(.text+0x38):ben.cpp: undefined
refer
ence to `std::basic_ostream<char, std::char_traits<char> >& std::operator<<
<std
::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&,
char c
onst*)''
C:\DOCUME~1\benben\LOCALS~1\Temp/ccojbaaa.o(.text+0x64):ben.cpp: undefined
refer
ence to `std::ios_base::Init::Init()''
C:\DOCUME~1\benben\LOCALS~1\Temp/ccojbaaa.o(.text+0x83):ben.cpp: undefined
refer
ence to `std::ios_base::Init::~Init()''
What has happend? Could anyone help me?
推荐答案
ben写道:
ben wrote:
当我尝试gcc下面的Helloworld程序时:
#include< iostream>
{
使用命名空间std;
cout<< 你好,世界!! \ n;
返回0;
}
我有错误如下:
snip
发生了什么事?有人可以帮助我吗?
When I try to gcc the following Helloworld program:
#include <iostream>
int main()
{
using namespace std;
cout << "Hello, World!!\n";
return 0;
}
I got errors as follows:
snip
What has happend? Could anyone help me?
你声明使用命名空间std;在main()里面...它应该在外面。
-
Alvin
You declare "using namespace std;" inside of main()...it should be outside.
--
Alvin
"本" <是****** @ hotmail.com>写道:
"ben" <be******@hotmail.com> writes:
当我尝试gcc
试试g ++
?
Try g++
?
ben写道:
ben wrote:
当我尝试gcc以下Helloworld计划时:
#include< iostream>
int main()
{
使用命名空间std;
cout<< 你好,世界!! \ n;
返回0;
}
我有错误如下:
C:\文档和设置\benben> gcc ben.cpp
C:\ DOCUME~1 \benben\LOCALS~1\Temp / ccojbaaa.o(。text + 0x33):ben.cpp:undefined
请参阅`std :: cout''
C:\ DOCUME~1 \benben\LOCALS~1\Temp / ccojbaaa.o(。text + 0x38): ben.cpp:undefined
请参阅`std :: basic_ostream< char,std :: char_traits< char> >&
std :: operator<< < std
:: char_traits< char> >(std :: basic_ostream< char,std :: char_traits< char>>&,
char c
onst *)''
C:\DOCUME~1 \ benben\LOCALS~1\Temp / ccojbaaa.o(。text + 0x64):ben.cpp:undefined
请参阅`std :: ios_base :: Init :: Init()' '
C:\ DOCUME~1\benben\LOCALS~1\Temp / ccojbaaa.o(。text + 0x83):ben.cpp:undefined
参考
`std :: ios_base :: Init :: ~Init()''
发生了什么事?
您使用编译器的方式错误。
任何人都可以帮助我吗?
When I try to gcc the following Helloworld program:
#include <iostream>
int main()
{
using namespace std;
cout << "Hello, World!!\n";
return 0;
}
I got errors as follows:
C:\Documents and Settings\benben>gcc ben.cpp
C:\DOCUME~1\benben\LOCALS~1\Temp/ccojbaaa.o(.text+0x33):ben.cpp: undefined
refer
ence to `std::cout''
C:\DOCUME~1\benben\LOCALS~1\Temp/ccojbaaa.o(.text+0x38):ben.cpp: undefined
refer
ence to `std::basic_ostream<char, std::char_traits<char> >&
std::operator<< <std
::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&,
char c
onst*)''
C:\DOCUME~1\benben\LOCALS~1\Temp/ccojbaaa.o(.text+0x64):ben.cpp: undefined
refer
ence to `std::ios_base::Init::Init()''
C:\DOCUME~1\benben\LOCALS~1\Temp/ccojbaaa.o(.text+0x83):ben.cpp: undefined
refer
ence to `std::ios_base::Init::~Init()''
What has happend?
You used the compiler the wrong way.
Could anyone help me?
试试用g ++而不是gcc。
Try with g++ instead of gcc.
这篇关于这个helloworld计划有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!