LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-02-2009, 04:38 AM   #1
icecubeflower
Member
 
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 304

Rep: Reputation: 33
what is std_lib_facilities.h


I'm working through the new Stroustrup book, front to back. His hello world program won't compile.
Code:
#include "std_lib_facilities.h"

int main()
{
   cout<<"Hello, World!\n";
   return 0;
}
Code:
icecube@inferno:~/bjarne$ g++ hello.cpp -o hello
hello.cpp:1:32: error: std_lib_facilities.h: No such file or directory
hello.cpp: In function 'int main()':
hello.cpp:9: error: 'cout' was not declared in this scope
icecube@inferno:~/bjarne$
That header file is in quotes, not these: <> So it's supposed to be in the same directory as my .cpp file? Why would I have that header file there?

I did this:
root@inferno:/home/icecube# find / -name std_lib_facilities.h
root@inferno:/home/icecube#

I don't think that header file even exists on my system. I don't get it, he acts like that header is standard on every system.

Last edited by icecubeflower; 04-02-2009 at 04:48 AM.
 
Old 04-02-2009, 04:45 AM   #2
icecubeflower
Member
 
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 304

Original Poster
Rep: Reputation: 33
I found this on his website, I think it's std_lib_facilities.h
Code:
//
// This is a standard library support code to the chapters of the book
// "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup
//

#ifndef STD_LIB_FACILITIES_GUARD
#define STD_LIB_FACILITIES_GUARD 1

#include <cmath>
#include <cstring>
#include <fstream>
#include <stdexcept>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

//------------------------------------------------------------------------------

// Helper function to show an error message
inline void error(const string& errormessage)
{
    throw runtime_error(errormessage);
}

//------------------------------------------------------------------------------

inline void error(string s1, string s2)
{
    error(s1+s2);
}

//------------------------------------------------------------------------------

#endif // STD_LIB_FACILITIES_GUARD
That still wouldn't make my program compile, it doesn't have #include <iostream> in it. What the hell.
 
Old 04-02-2009, 04:51 AM   #3
Udi
Member
 
Registered: Jan 2009
Posts: 165

Rep: Reputation: 44
Go back to the web site: http://www.stroustrup.com/Programming/

There is a link that is called "Standard library access header" which you can find right near the quote that you provided in your first post. It points to the header file.

If you still can't find it: http://www.stroustrup.com/Programmin...b_facilities.h
 
Old 04-02-2009, 05:10 AM   #4
icecubeflower
Member
 
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 304

Original Poster
Rep: Reputation: 33
Oh. Oops. For some reason it didn't dawn on me that that was a link to a file. I was looking at it like it was the title of the next three lines. I must be tired.

Yeah on page 46 he says: "We wrote that file to simplify use of the facilities available in all implementations of C++"

I wish he would have just said, "HEY! You gotta go download this .h file and stick in the same directory as your .cpp file!"
 
Old 04-02-2009, 07:38 AM   #5
icecubeflower
Member
 
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 304

Original Poster
Rep: Reputation: 33
Hey once you get to page 53 he does tell you to download it and he tells you where to get it. I guess I wasn't supposed to try to compile his program until he told me too, oops.

There's a terrible typo on page 53, though, he tells you to go to Appendix D to set up a project but Appendix D is about FLTK. I went and set up FLTK and made a "hello world" window but the code he has next doesn't even use FLTK. I think he meant Appendix C?
 
Old 07-19-2010, 08:07 PM   #6
dagiffy
LQ Newbie
 
Registered: Jul 2010
Posts: 2

Rep: Reputation: 0
std_lib_facilities.h

I've been having some problems with this and found this fine forum with Google. I am going through the same text as the OP. In appendix C, the author states:

"Place a copy of it (which I have found via the above posts) in the directory you chose (for your project). (Note: save as text, not HTML.) To use it, you need the line

#include "../../std_lib_facilities.h"

in your program. The "../../" tells the compiler that you placed the header in C:\Documents and Settings\Your Name\My Documents\Visual Studio 2xxx\Projects where it can be used with all your projects, rather than right next to your source file in a project where you would have to copy it for each project."

Well, I've done that. Or so I think. I copy/pasted the std_lib_facilities.h program into a text file and saved it in the Projects folder. I named it std_lib_facilities.h, for lack of a better idea. My compiler still can't open it or access it? Any ideas?

Last edited by dagiffy; 07-19-2010 at 09:13 PM. Reason: found solution
 
Old 07-19-2010, 09:13 PM   #7
dagiffy
LQ Newbie
 
Registered: Jul 2010
Posts: 2

Rep: Reputation: 0
My error apparently was that compilers don't open text documents when they are looking for headers. I r-clicked on the link and saved in Projects, now everything works fine.
 
  


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



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

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