LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-01-2007, 09:15 PM   #1
jaepi
Member
 
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189
Blog Entries: 1

Rep: Reputation: 30
help with VI and gcc T_T


iv'e already installed gcc, im trying to compile my hello_world.cpp but it produces an error(is my command correct -->> "[dinglej@localhost bin]$ gcc hello_world.cpp")...wah..dunno what's wrong with my set-up...here's the error...

hello_world.cpp: In function `int main()':
hello_world.cpp:5: error: `cout' undeclared (first use this function)
hello_world.cpp:5: error: (Each undeclared identifier is reported only once for each function it appears in.)

help pls..
 
Old 05-01-2007, 09:18 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
You should use g++ to compile C++ code. Also, did you remember to put "using namespace std;" or use std::cout? Modern C++ compilers expect that the correct namespace (std) be used.
 
Old 05-01-2007, 09:20 PM   #3
jaepi
Member
 
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189
Blog Entries: 1

Original Poster
Rep: Reputation: 30
lol...there's something wrong with my command...bwahahah...the correct command to use is...

[dinglej@localhost bin]$ g++ sample.cpp -o sample

then run it using this command...

[dinglej@localhost bin]$ sample

hahahah...nyay

 
Old 05-01-2007, 09:20 PM   #4
chuckbuhler
Member
 
Registered: Oct 2005
Distribution: SuSe
Posts: 95

Rep: Reputation: 17
post your code. Sounds like stdio.h is not included.

Edit: just re-read the post. I'm just an old perl / c programmer, so not sure if that's needed for c++, so ignore this post.

Last edited by chuckbuhler; 05-01-2007 at 09:23 PM.
 
Old 05-01-2007, 09:25 PM   #5
jaepi
Member
 
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189
Blog Entries: 1

Original Poster
Rep: Reputation: 30
here's my code
#include <iostream>

int main(){

std::cout << "Hello World!" << std::endl;
return 0;
}

i now know how to compile...nyehehe...my command was so so so wrong...nyay...thank you everyone..bwahaha...funny me..
 
Old 05-01-2007, 10:14 PM   #6
chuckbuhler
Member
 
Registered: Oct 2005
Distribution: SuSe
Posts: 95

Rep: Reputation: 17
I just copied your code to a text file, added a newline to the end, and used the commmand:

g++ hw.cpp -o sample

and got a good compile

./ sample

properly printed out the "Hello World" statement

So, I don't think it's a problem with your code, something is missing in your install.

I'm not a c++ programmer, so guess I'll leave it to the experts.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help please T_T im almost done w/ this...T_T bookgekgom Linux - Software 5 12-29-2006 03:21 AM
teach me some more about LVM T_T bookgekgom Linux - Newbie 2 12-23-2006 03:26 PM
PCG-FRV26 startx Fatal Error T_T TextBrowserAddict Linux - Laptop and Netbook 1 08-24-2005 04:32 AM
Toshiba Satellite 4300 Pro T_T problemo robot2051 Linux - Laptop and Netbook 0 08-08-2005 01:30 PM


All times are GMT -5. The time now is 08:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration