LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 03-02-2008, 02:19 AM   #1
khandielas
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Rep: Reputation: 0
g++ compiler cannot locate its library in my fedora machine


Hi, all, new to LINUX. cannot successfully compile.
I run fedora 7, gcc version
[root@ Basics]# gcc --version
gcc (GCC) 4.1.2 20070925 (Red Hat 4.1.2-27)

I can find gcc library under /usr/include/c++/4.1.2/iostream

#include <iosteam>
int main()
{
cout << "hello, world" << endl;
return 0;
}

I got this when compuling:
[root@ Basics]# g++ hello.cpp
hello.cpp: In function ‘int main()’:
hello.cpp:5: error: ‘cout’ was not declared in this scope
hello.cpp:5: error: ‘endl’ was not declared in this scope

a piece of test code:
int main() { return 0 }
#g++ test.cpp
It does not show any error.
 
Old 03-02-2008, 08:51 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
You need to either add a "using namespace std;" line below your include directive, or change "cout" and "endl" to "std::cout" and "std::endl" respectively.

Also, you're not using the root account all the time are you? If so, you really should make a regular user account for everyday use.
 
Old 03-02-2008, 12:46 PM   #3
khandielas
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Thumbs up

Quote:
Originally Posted by Nylex View Post
You need to either add a "using namespace std;" line below your include directive, or change "cout" and "endl" to "std::cout" and "std::endl" respectively.

Also, you're not using the root account all the time are you? If so, you really should make a regular user account for everyday use.
Thank you very much. It works fine with std namespace. Thought compiler always choose std as default -. I also created user acct, thanks for the reminder!
 
  


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
c++ compiler doesn't find library Y0jiMb0 Linux - General 7 12-27-2010 06:27 AM
How to tell compiler to not to use GNU library (glibc) P.S.R.K.S.PRASAD Linux - Kernel 1 12-27-2006 03:58 AM
Know compiler version of an already built library azazel11998 Programming 1 11-12-2006 06:11 AM
locate infected machine from dhcp server erimar77 Linux - General 2 05-20-2006 10:33 AM
X Windows and compiler library issues fiveball02 *BSD 2 10-27-2005 08:41 PM


All times are GMT -5. The time now is 07:33 PM.

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