LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-02-2003, 02:16 PM   #1
grim1234
Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware 10.2, Fluxbox.
Posts: 64

Rep: Reputation: 15
Talking Can't get past Hello World.


I'm just starting to program in C++, I have a little perl experience.

So far I don't have a problem understanding the code but as I using an oldish book (Stroustrup, 3rd Ed, 1997) some things seem to have changed (maybe). I'm trying to compile a hello world program -

---first.cpp:
#include <iostream>

int main()
{
std::cout<< "Hello, LQ!\n";
}
---

and I get -

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

Where am I going wrong? Perhaps something more related to linux would help? Input is welcome.

Thanks,

Graham.



Last edited by grim1234; 09-02-2003 at 04:48 PM.
 
Old 09-02-2003, 02:34 PM   #2
jinksys
Member
 
Registered: Aug 2003
Location: 63123
Distribution: OpenSuSE/Ubuntu
Posts: 419

Rep: Reputation: 35
Hey Graham,

This is a simple problem.
You are trying to compile a C++ program with a C compiler.
You need to use g++.
To make the executable "first" type this...

g++ -o first first.cpp


Last edited by jinksys; 09-02-2003 at 02:35 PM.
 
Old 09-02-2003, 04:41 PM   #3
grim1234
Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware 10.2, Fluxbox.
Posts: 64

Original Poster
Rep: Reputation: 15
excellent. now only the rest of the language to master.

Thanks!

 
  


Reply



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
basic speel Programming 4 05-10-2005 10:40 AM
Newbie basic errors? Only root runs X, games does not work. fipeso Linux - Newbie 13 04-14-2005 08:29 PM
Errors during filesystem check with one kernel while no errors with other kernel Potentials Linux - General 11 12-30-2003 04:24 AM
QMAIL errors errors.. YourForum Linux - Software 0 11-27-2003 12:30 PM
I'm a BASIC chap, looking for some info on BASIC programming CragStar Programming 2 01-21-2001 09:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:41 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
Open Source Consulting | Domain Registration