Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-03-2005, 12:54 AM   #1
LQ Newbie
Registered: Jun 2003
Distribution: RedHat
Posts: 9

Rep: Reputation: 0
Unhappy Newbie having problems w/ gcc and g++

Hello all -

I'm new to linux, and I just got a nice redhat 9 system set up. Everything is working the way I want it to, and I am very impressed w/ linux and everything else so far. However, I am having a problem with g++. It doesn't seem to be able to find any libraries. For instance, when compiling the simple hello world program that follows:

#include <iostream>

int main()
cout << "Hello World!\n";

return 0;

I use the command 'g++ hello.cpp -o hello' and get the following set of error messages:

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

I get the same type of messages if I try to use anything w/ string, even after doing a #include <string>.

It's my understanding that g++ looks in /usr/lib and /lib for libraries when it is doing a complile.
I looked in both of those dirs, and they do have files (this is where I show my c++ newbie status as well) but neither dir had anything called iostream or any related name that i could find.

So I guess the question really is... where are all of the common libraries (like iostream and string) placed on a linux system, what exactly are the files called, and how can I tell g++ to look in those dirs if it isn't allready.

I have read the man page for g++ and also tried extensive googling for an answer to this question, but have not been able to find anything =( Any help that you can offer would be greatly appreciated =)
Old 01-03-2005, 01:03 AM   #2
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Use std::cout -- on modern C++ implementations the std namespace is not imported by default.

Oh, and this probably should've been posted in the programming forum.
Old 01-03-2005, 01:07 AM   #3
LQ Newbie
Registered: Jun 2003
Distribution: RedHat
Posts: 9

Original Poster
Rep: Reputation: 0
*blushes deep crimson* haha - sad thing is i knew that, it just slipped my mind... oopsie. Thanx for the help tho =) Sorry if posted in the wrong catagory, it just sounded like a newbiesh question.


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
gcc- newbie question babambar Linspire/Freespire 3 11-09-2005 06:31 PM
Newbie: how to define cc/gcc path LFCsion Mandriva 3 08-26-2005 04:32 AM
GCC newbie compile question crisponions Programming 2 07-08-2004 08:16 PM
Newbie seeks upgrade glibc & gcc on SuSE 7.0 sfarber53 Linux - Newbie 2 01-14-2004 10:17 AM
Installing GCC Newbie... Mentor Linux - Software 5 06-12-2003 06:50 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:56 AM.

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