LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 08-21-2012, 05:27 AM   #1
HarryBoy
Member
 
Registered: Apr 2008
Distribution: MontaVista Linux Version 4.0.1, Professional Edition
Posts: 215

Rep: Reputation: 16
makefile include <iostream.h> question


I'm trying to learn makefiles and have started here:
http://mrbook.org/tutorials/make/

I get the following error:

Code:
myLinuxBox:/home/user/makefiles # g++ main.cpp hello.cpp factorial.cpp -o hello
main.cpp:1:22: error: iostream.h: No such file or directory
main.cpp: In function âint main()â:
main.cpp:6: error: âcoutâ was not declared in this scope
main.cpp:6: error: âendlâ was not declared in this scope
hello.cpp:1:22: error: iostream.h: No such file or directory
hello.cpp: In function âvoid print_hello()â:
hello.cpp:5: error: âcoutâ was not declared in this scope
The main.cpp is simply:

Code:
#include <iostream.h>
#include "functions.h"

int main(){
    print_hello();
    cout << endl;
    cout << "The factorial of 5 is " << factorial(5) << endl;
    return 0;
}

How do I include the iostream.h properly??
 
Old 08-21-2012, 05:31 AM   #2
gregAstley
LQ Newbie
 
Registered: Aug 2012
Distribution: ubuntu 11.10
Posts: 27

Rep: Reputation: 4
Quote:
Originally Posted by HarryBoy View Post
I'm trying to learn makefiles and have started here:
http://mrbook.org/tutorials/make/

I get the following error:

Code:
myLinuxBox:/home/user/makefiles # g++ main.cpp hello.cpp factorial.cpp -o hello
main.cpp:1:22: error: iostream.h: No such file or directory
main.cpp: In function âint main()â:
main.cpp:6: error: âcoutâ was not declared in this scope
main.cpp:6: error: âendlâ was not declared in this scope
hello.cpp:1:22: error: iostream.h: No such file or directory
hello.cpp: In function âvoid print_hello()â:
hello.cpp:5: error: âcoutâ was not declared in this scope
The main.cpp is simply:

Code:
#include <iostream.h>
#include "functions.h"

int main(){
    print_hello();
    cout << endl;
    cout << "The factorial of 5 is " << factorial(5) << endl;
    return 0;
}

How do I include the iostream.h properly??
have you tried simply #include <iostream> ?
i.e. leave out the ".h"
 
Old 08-21-2012, 05:36 AM   #3
HarryBoy
Member
 
Registered: Apr 2008
Distribution: MontaVista Linux Version 4.0.1, Professional Edition
Posts: 215

Original Poster
Rep: Reputation: 16
Thanks for your reply. I did this and it does not complain about not finding it but it complains on the cout:


Quote:
main.cpp: In function âint main()â:
main.cpp:6: error: âcoutâ was not declared in this scope
main.cpp:6: error: âendlâ was not declared in this scope
Any other ideas??
 
Old 08-21-2012, 05:42 AM   #4
gregAstley
LQ Newbie
 
Registered: Aug 2012
Distribution: ubuntu 11.10
Posts: 27

Rep: Reputation: 4
Quote:
Originally Posted by HarryBoy View Post
Thanks for your reply. I did this and it does not complain about not finding it but it complains on the cout:




Any other ideas??
ah yes...cout is in the std namespace so in order to use it you have to specify the namespace, for example: std::cout << "blah";
You can also import the name space entirely (bad idea usually) by
using namespace std; in which case you don't need the "std::" prefix. You can also import individual elements from the namespace (better than getting all of them) by
using std::cout; (and again you can then drop the prefix)
 
Old 08-21-2012, 06:23 AM   #5
HarryBoy
Member
 
Registered: Apr 2008
Distribution: MontaVista Linux Version 4.0.1, Professional Edition
Posts: 215

Original Poster
Rep: Reputation: 16
excellent, 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
How to include my helloworld.c into makefile? dennisdd Linux - Newbie 7 10-19-2011 03:39 AM
my iostream.h include won't work slinky2004 Programming 5 09-20-2005 12:37 AM
GCC:- 'cout' is an undeclared function when #include <iostream> is included? caesius_01 Programming 5 04-04-2004 11:00 AM
g++ why cant i #include \<iostream\> ??? qwijibow Programming 4 10-03-2003 07:17 AM
#include <iostream> ERROR alexrm1x Programming 9 03-14-2003 10:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:03 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