Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-31-2003, 06:51 AM   #1 (permalink)
mangeli
Registered User
 
Join Date: Mar 2003
Posts: 4
mangeli is on a distinguished road
Send a message via AIM to mangeli
Problem Compiling...

Ok, I'm a newbie, so bear with me...
I'm running Mandrake 9.1.

I picked up a copy of Sams Teach yourself C++ in 21 days, and I created my hello.cpp file.

Code:
#include <iostream>

int main()
{
     std::cout << "Hello World!\n";
     return 0;
}
I know, its the most basic thing all programmers learn to do.

However, when I run

Code:
#: gcc -o hello hello.cpp
I get errors and nothing is created.
Quote:
In function `main' :
: undefined reference to `std::cout'
and it goes from there....
mangeli is offline   Reply With Quote
Old 03-31-2003, 07:31 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,692
redhead is on a distinguished road
just remove the std:: infront of cout, and everything should be fine.

So the code would be:
Code:
#include <iostream>

int main()
{
    cout << "Hello world\n";
    return  0;
}
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 03-31-2003, 08:50 AM   #3 (permalink)
mangeli
Registered User
 
Join Date: Mar 2003
Posts: 4
mangeli is on a distinguished road
Send a message via AIM to mangeli
I alread tried that. I get
Quote:
`cout' undeclaired (first use this function)
mangeli is offline   Reply With Quote
Old 03-31-2003, 09:30 AM   #4 (permalink)
Travis Dane
Code Monkey
 
Travis Dane's Avatar
 
Join Date: Feb 2003
Location: Netherlands
Posts: 89
Travis Dane is on a distinguished road
Send a message via ICQ to Travis Dane
Redhead: He actually must put "std::" before it since he isn't
using the namespace "std".

Mangeli: I suggest you include <iostream.h> instead of
<iostream>, It might be that you still have the old iostream.
__________________
OpenGL, DirectX
Travis Dane is offline   Reply With Quote
Old 03-31-2003, 10:32 AM   #5 (permalink)
mangeli
Registered User
 
Join Date: Mar 2003
Posts: 4
mangeli is on a distinguished road
Send a message via AIM to mangeli
when I try iostream.h I get an error about that being the old version of GCC (I'm running 3.2.2)
mangeli is offline   Reply With Quote
Old 03-31-2003, 11:01 AM   #6 (permalink)
Unicorn
Registered User
 
Unicorn's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 11
Unicorn is on a distinguished road
Try 'g++' instead of 'gcc', that might work.
Unicorn is offline   Reply With Quote
Old 03-31-2003, 11:09 AM   #7 (permalink)
mangeli
Registered User
 
Join Date: Mar 2003
Posts: 4
mangeli is on a distinguished road
Send a message via AIM to mangeli
Quote:
Originally posted by Unicorn
Try 'g++' instead of 'gcc', that might work.
That got it.

Thanks.
mangeli is offline   Reply With Quote
Old 03-31-2003, 02:56 PM   #8 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
LOL Duh! :p

Ilya.
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with editing profile cheawick Feedback 0 04-28-2004 10:26 PM
strange posting problem on my website......... trevor PHP 2 12-19-2003 12:25 PM
Help debugging a power problem Belisarius Lounge 0 10-25-2003 04:44 PM
This is a windows/C problem UnderWing Standard C, C++ 6 03-28-2003 06:17 AM
PHP / JS problem bdl HTML, XML, Javascript, AJAX 2 03-13-2003 08:53 AM


All times are GMT -8. The time now is 08:41 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting