Click to See Complete Forum and Search --> : Need Header Files....


redline
04-18-2001, 08:56 PM
I am trying to finish up a program for school,
but I do not know where to get header files (iostream.h, etc) anyone please help?!

thanks,
redline

Ben Briggs
04-18-2001, 09:03 PM
Those are C++ header files... you'll need to install your distros package for C++ or compile from source. If you chose the source route... GNU (http://www.gnu.org) is the place to go.

redline
04-18-2001, 09:17 PM
I have the gcc and teh c++ package installed..it cannot find ANY header files.

Any ideas as to where they would be?

thanks,
redline

kmj
04-18-2001, 09:29 PM
you can do a

find -regex .*\.h -print

That will list all the header files;

IIRC, they should be in "/usr/include", so you might want to look there first.

If they aren't there, then you might have missed a package during installation... which can be a pain in the ***, and seems to happen all to often for those who don't do a custom install.

redline
04-18-2001, 09:34 PM
is there anywhere where i can download header files? I am still missing iostream.h, istream, ostream, and stdcomp.h.

thanks,
redline

Bradmont
04-18-2001, 09:43 PM
Doesn't #include <iostream>
using namespace std;


Work? If your headers are installed, that should be all you need.... if that doesn't work, you'll need to install them.

redline
04-18-2001, 09:50 PM
The /usr/include dir exists and is full of headers, but this is what I get...

redline]# gcc test.cpp
test.cpp:1:iostream: No such file or directory
redline]#

what other packages would I need to install?

thanks
redline

[ 18 April 2001: Message edited by: redline ]

Ben Briggs
04-18-2001, 10:46 PM
Does your source look like this:


#include "iostream.h"

or like:

#include <iostream.h>


If it's the top one... that's your problem. The quotes are for headers in the current directory, the brackets (<> ) are for in the standard header direcory (usally /usr/include).

If that's isn't the problem, could you post the code? Also, what distro are you using? If it Red Hat, I've head war stories about getting the gcc rpm to work properly, people end up just compiling a new one from GNU.

Ben Briggs
04-18-2001, 10:48 PM
Originally posted by redline:
<STRONG>The /usr/include dir exists and is full of headers, but this is what I get...

redline]# gcc test.cpp
test.cpp:1:iostream: No such file or directory
redline]#

what other packages would I need to install?

thanks
redline

[ 18 April 2001: Message edited by: redline ]</STRONG>

Rereading you post the answer just struck me... you're using gcc to compile C++, you need to use g++ or gpp (depending on your distro) :).

redline
04-18-2001, 11:14 PM
#include &lt;iostream.h&gt;
using namespace std;

int main()
{
cout&lt;&lt;"test"&lt;&lt;endl;
return 0;
}


This is the program that I am trying to compile. I am using Drake 7.1 right now.
g++ gives same error.

thanks,
redline

Ben Briggs
04-18-2001, 11:42 PM
Cheeze-o-man, I'm clueless :(. The only thing else I can suggest to you (without sending you my iostream header (which I'll do later tonight when I get on my Linux box)) is try commenting out the namespace line. I'm a C dood myself, so I don't know what that stuff is :).

tnordloh
04-19-2001, 02:21 AM
It compiled fine for me on my pc. I'm thinking a total uninstall and reinstall on gcc may be in order...


If that seems a little too drastic, try this command;

g++ -L-/usr/include test.cpp

From what TFM says, that -L- command tells gcc to check the directory supplied for header files. I'm going to go check out info now and see if it says where the include directory is referenced in gcc. If I can figure it out, I'll post it.

[ 19 April 2001: Message edited by: tnordloh ]

tnordloh
04-19-2001, 02:37 AM
I'm reading the info page now. By the way, I'm assuming you did something on the install to fsck up your gcc, so tell me if there is something unusual about your install. If it's a total by-the-book setup, installed with the os, were there any glitches during that install? They mention several possible things that could go wrong in the info page, night want to check it out...

I don't mean to offend, just want a touch more troubleshooting info...


Ok, I'm bored now, and I'm going to stop reading. Here's one final tidbit.

If you simply installed gcc from the command line without options, its default header library is /usr/local/include. If all of your headers are in /usr/include, this is obviously no good. I suggest creating a symbolic link to this directory with the command as root;

ln -s /usr/include /usr/local/include

That's it for me, hope one of those ideas work. I see a ducky outside my window, and it is distracting me. Bye bye....

[ 19 April 2001: Message edited by: tnordloh ]

Bradmont
04-19-2001, 05:11 AM
Take the ".h" out of &lt;iostream.h&gt;

It should just be like this:


#include &lt;iostream&gt;
using namespace std;

int main()
{
cout &lt;&lt; "Moo\n";
return 0;
}

Bradmont
04-19-2001, 05:12 AM
Bradmont's right. That's your problem!

kmj
04-19-2001, 10:18 AM
I'm glad you're there to back yourself up, bradmont. :)

Ben Briggs
04-19-2001, 11:10 AM
Bradmont: In C++, the .h is optional... but you also don't have to leave it off :).

tnordloh
04-20-2001, 02:12 AM
ben is right. I am able to compile both ways, and I even forgot to put in the using namespace std; line. Worked fine both ways.

SiM
04-20-2001, 12:30 PM
hahahaha, yeah bradmont... way to back yourself up there buddy, that's some funny stuff.
SiM

flynnwallace
04-21-2001, 06:06 PM
Mandrake 6.1-7.2 will sometimes not include all of the files needed for the GNC compiler. Check with the rpm manager to see it all files related to C++ are installed on your system. I have helped about 10 people so far with exactly the same problem. It happened to me also.

Flynn

pinoy
04-21-2001, 09:33 PM
Bradmont is right. The C++ *Standard* specifies headers without the ".h". The .h are basically for compatibility of old software. When including standard header files without the .h, all classes, functions, etc are stored in the std namespace. The .h version imports it into your global namespace.

Even the Standard C library has been changed in the C++ library. They should be included as &lt;cstdio&gt; &lt;cstdlib&gt; &lt;cstring&gt;, etc.

Stoofer
11-08-2003, 10:51 AM
hi,

I'm stuggling with the "where is iostream.h" problem too.

did this:-

chris@slackbox:/usr/local/include$ find -regex .*\.h -print
chris@slackbox:/usr/local/include$

Which indicates I have no libraries. so did it at the root directory to find I listed what looks like everything installed on my machine.

changed to root and did:



root@slackbox:/# find -regex .*\iostream.h -print
./usr/include/c++/3.2.3/backward/iostream.h
./usr/include/php/Zend/zend_istdiostream.h
root@slackbox:/#

I'll try a link to this new location.
did it
then did: and got:

chris@slackbox:~$ gcc farenheitcelcius.c -o Conv
In file included from farenheitcelcius.c:7:
/usr/include/iostream.h:31:30: backward_warning.h: No such file or directory
/usr/include/iostream.h:32:20: iostream: No such file or directory
In file included from farenheitcelcius.c:7:
/usr/include/iostream.h:34: syntax error before "std"
farenheitcelcius.c: In function `main':
farenheitcelcius.c:12: `cout' undeclared (first use in this function)
farenheitcelcius.c:12: (Each undeclared identifier is reported only once
farenheitcelcius.c:12: for each function it appears in.)
farenheitcelcius.c:13: `cin' undeclared (first use in this function)
chris@slackbox:~$

which tells me that I need the right library in there in the first place not a link to a "backward" (I read older) library.

newbie's brain hurts.

What Do I try now?

tecknophreak
11-08-2003, 12:18 PM
Originally posted by Stoofer
hi,


did this:-

chris@slackbox:/usr/local/include$ find -regex .*\.h -print
chris@slackbox:/usr/local/include$

Which indicates I have no libraries. so did it at the root directory to find I listed what looks like everything installed on my machine.



nah, that just means you don't have any files named ".h" in that directory. try
find -regex .*\*.h

That'll list the files.

to find iostream try

find -regex .*\iostream


chris@slackbox:~$ gcc farenheitcelcius.c -o Conv


if you use iostream in your prog, it needs to be c++, not c, since it's part of c++ and not c. try


cp farenheitcelcius.c farenheitcelcius.cpp
g++ farenheightcelcius.cpp -o Conv


also try including iostream as they've been saying in this thread:


#include <iostream>
using namespace std;


good luck

bwkaz
11-08-2003, 04:48 PM
Stoofer, I think you're a slight bit confused.

<iostream> and <iostream.h> are not libraries. They're header files. You do not link them into anything, you include them in your source files.

---

The reason they weren't being found before is what tecknophreak posted -- you're using a C compiler (gcc), and <iostream> / <iostream.h> are C++ header files. You do not need to (and should not) symlink /usr/include/c++/anything into /usr/include, because g++ automatically searches /usr/include/c++/$(g++ -dumpversion)/include for include files. (The second header that it complained about is in the same directory, BTW.)

Stoofer
11-10-2003, 05:42 AM
That is certainly one problem I face. I have been confused by starting a "C++ crashcourse in a weekend" book and then referencing to debug from "C for dummies" vols 1&2.

I appologise now for the high density of questions in this post. It might surpriseyou to discover I am not actually trying to win an award for it. :p

I realised this but I still haven't been consistant since I thought gcc recognised C++ and did what it needs to. I didn't realise you needed to be that strict by calling g++. I'll try that when i get home from work (grad design engineer - -mech).

Still this doesn't answer: why is my header file in /usr/include/g++/3.2.3/backward/iostream.h and not in /usr/include, or /usr/local/include? I run slack9.1 (great for a newbie, I have to get it all working yet and I've had it for 6 weeks). is it normal for iostream.h to have such a long path? And further, since it is there does that mean I am missing nothing? (in terms of headers?):confused:

I have deinstalled and reintsalled the whole thing (gcc) using swaret, so I think everything that come with gcc sould be there although there are no c++ packages in the collection (as far as I could discern) are gcc and g++ two totally different packages?:confused:

And what is the difference between a header and a library? i remember reading a c/c++ book years ago and it talked aout headers and libraries apparently interchangeably. I was 13 at the time (11 years ago). :rolleyes:

DO you think if I use some crazy matrix maths (cos I can:p) in my newbie fahrenheit-to-celcius-conversion code then I can patent it? Hmmm, Make a bit of money?


IT WAS A JOKE!! DONT FLAME ME!!!!

Stoofer
11-10-2003, 03:36 PM
I ammended the code and changed to using G++ with the new source file name. I got diferent errors:

chris@slackbox:~$ g++ farenheitcelcius.cpp -o Conv
In file included from /usr/include/c++/3.2.3/backward/iostream.h:31,
from farenheitcelcius.cpp:7:
/usr/include/c++/3.2.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
farenheitcelcius.cpp:8: syntax error before `:' token
farenheitcelcius.cpp:13: syntax error before `<<' token
farenheitcelcius.cpp:14: syntax error before `>' token
farenheitcelcius.cpp:19: ISO C++ forbids declaration of `nFactor' with no type
farenheitcelcius.cpp:19: redefinition of `int nFactor'
farenheitcelcius.cpp:18: `int nFactor' previously declared here
farenheitcelcius.cpp:24: ISO C++ forbids declaration of `nFahrenheit' with no
type
farenheitcelcius.cpp:24: redefinition of `int nFahrenheit'
farenheitcelcius.cpp:23: `int nFahrenheit' previously declared here
farenheitcelcius.cpp:24: `nFactor' was not declared in this scope
farenheitcelcius.cpp:24: `nCelcius' was not declared in this scope
farenheitcelcius.cpp:27: syntax error before `<<' token
farenheitcelcius.cpp:28: `nFahrenheit' was not declared in this scope
farenheitcelcius.cpp:28: syntax error before `;' token
/usr/include/c++/3.2.3/bits/stl_algobase.h: In function `const _Tp&
std::min(const _Tp&, const _Tp&) [with _Tp = size_t]':
/usr/include/c++/3.2.3/bits/stl_algobase.h:793: instantiated from here
/usr/include/c++/3.2.3/bits/stl_algobase.h:153: `__a' undeclared (first use
this function)
/usr/include/c++/3.2.3/bits/stl_algobase.h:153: (Each undeclared identifier is
reported only once for each function it appears in.)
/usr/include/c++/3.2.3/bits/stl_algobase.h:153: `__b' undeclared (first use
this function)
/usr/include/c++/3.2.3/bits/stl_algobase.h: In function `bool
std::lexicographical_compare(_InputIter1, _InputIter1, _InputIter2,
_InputIter2) [with _InputIter1 = const signed char*, _InputIter2 = const
signed char*]':
/usr/include/c++/3.2.3/bits/stl_algobase.h:805: instantiated from here
/usr/include/c++/3.2.3/bits/stl_algobase.h:745: `__last2' undeclared (first use
this function)
/usr/include/c++/3.2.3/bits/stl_algobase.h:745: `__first2' undeclared (first
use this function)
/usr/include/c++/3.2.3/bits/stl_algobase.h:745: `__last1' undeclared (first use
this function)
/usr/include/c++/3.2.3/bits/stl_algobase.h:745: `__first1' undeclared (first
use this function)
/usr/include/c++/3.2.3/cmath: In function `_Tp std::__pow_helper(_Tp, int)
[with _Tp = double]':
/usr/include/c++/3.2.3/cmath:419: instantiated from here
/usr/include/c++/3.2.3/cmath:392: `__x' undeclared (first use this function)
/usr/include/c++/3.2.3/cmath:392: `__n' undeclared (first use this function)
/usr/include/c++/3.2.3/cmath:392: `__cmath_power' undeclared (first use this
function)


argh! ok now you want to see the code? Ok I copied it out of a book. :-

#include <stdio.h>
#include <iostream.h>
using namespace std:
int main(int nNumberofArgs, char* pszArgs[])
{
// unter the temperature in celcius
int nCelcius;
cout <<"Enter the temperature in Celcius:";
cin > nCelcius;

// calculate conversion factor for celcius
// to farenherit
int nFactor;
nFactor = 212-32;

// use conversion factor to convert celcius
// into farenheit values
int nFahrenheit;
nFahrenheit = nFactor * nCelcius/100 + 32;

// output the results
cout << "Farenheit values is:";
cout< nFahrenheit;

return 0;
}
It seems like the newbie book I bought to self teach c++ is telling me porkies about C++. I am sure some of that is c and not C++. and more interestingly, is there such a thing as iterations of C? Imean we get version number s of programs which take less effort to create than a whole langauge, so do we get versions of lagauges? Might I be trying to using "old C++" on a "newer" c++ compiler?

I can't believe I just asked that. But really I don't know?

mwinterberg
11-10-2003, 04:29 PM
Your problems are stemming from typos (three total). Review what the book has. If your typed up version of the program is exactly the same as in the book, return the book as soon as possible and buy a better one. (Actually, buy a better one anyway, as a language such as C++ isn't one to be "taught yourself in 4 hours".)

-Michael

tecknophreak
11-10-2003, 04:31 PM
Try to compile this, errors are commented out


#include <stdio.h>
#include <iostream>

using namespace std; // : // ERROR

int main(int nNumberofArgs, char* pszArgs[])
{
// unter the temperature in celcius
int nCelcius;
cout <<"Enter the temperature in Celcius:";
//cin > nCelcius; // ERROR
cin >> nCelcius;

// calculate conversion factor for celcius
// to farenherit
int nFactor;
nFactor = 212-32;

// use conversion factor to convert celcius
// into farenheit values
int nFahrenheit;
nFahrenheit = nFactor * nCelcius/100 + 32;

// output the results
cout << "Farenheit values is:";
//cout< nFahrenheit; // ERROR
cout << nFahrenheit;

return 0;
}


P.S. Please use the # button to post code makes it easier to read ;)

Stoofer
11-10-2003, 06:58 PM
hurray!!

with commenting out all the cin and cout references where a variable is refered I have found that it works!

cheers guys!

The next thing is making something useful since commenting out tyhese lines does this:-

chris@slackbox:~$ conv
Enter the temperature in Celcius:Farenheit values is:chris@slackbox:~$

I think there is insufficient formatting around the the cout << nFactor;

putting an nFahrenheit back i I got:-

chris@slackbox:~$ g++ farenheitcelcius.cpp -o conv
In file included from /usr/include/c++/3.2.3/backward/iostream.h:31,
from farenheitcelcius.cpp:7:
/usr/include/c++/3.2.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
farenheitcelcius.cpp: In function `int main(int, char**)':
farenheitcelcius.cpp:14: no match for `std::istream& > int&' operator

as compile errors.

So what is missing from my book?

Good start to programming though

bwkaz
11-10-2003, 07:27 PM
Originally posted by Stoofer
In file included from /usr/include/c++/3.2.3/backward/iostream.h:31,
from farenheitcelcius.cpp:7:
/usr/include/c++/3.2.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated. To get rid of this annoying warning (and to make sure your code continues to work after the G++ guys remove <iostream.h>), change <iostream.h> to just plain <iostream>. It isn't an error now, but sooner or later it will be (that's what happens to something that's deprecated after a while).

I'll skip my usual rant about "using namespace std;" because you're learning. You can read up on the right way to do importing from namespaces later. ;)

farenheitcelcius.cpp: In function `int main(int, char**)':
farenheitcelcius.cpp:14: no match for `std::istream& > int&' operator Looks like there aren't enough > symbols on one of your lines again. The compiler is looking for an overload of operator > (the greater-than operator) that will compare a std::istream reference to an int reference (as opposed to the "get" operator that is normally used with iostreams, to store the next "thing" from cin into the int variable).

Recheck the number of > symbols on line 14. There should be 2.

tecknophreak
11-11-2003, 08:59 AM
Originally posted by bwkaz


I'll skip my usual rant about "using namespace std;" because you're learning. You can read up on the right way to do importing from namespaces later. ;)


The official "using namespace std;" Nazi!! Was wondering if you'd throw that in here somewhere. :D

Stoofer
11-11-2003, 06:56 PM
That was a successful 2nd ever c++ program!!

It did this:-

chris@slackbox:~$ conv2
Enter the temperature in Celcius:23
Farenheit values is:73chris@slackbox:~$

Want to get a newline on there now!!

Right allegro 3D library now.

Joke.

Thanks for all your help everyone, its been, well, emotional.

ChriStoofer

bwkaz
11-11-2003, 07:37 PM
Originally posted by tecknophreak
The official "using namespace std;" Nazi!! Was wondering if you'd throw that in here somewhere. :D Hey now... :D

Stoofer -- you can add a newline at the end by changing the last line to:

std::cout << nFahrenheit << std::endl; (the two "std::" pieces aren't strictly necessary when you import the entire std namespace, but if you don't they'll fix the compiler issues you will get).

Stoofer
11-12-2003, 05:34 AM
I'll do that.

I is liking this code thing. when something works you get such a buzz!!:p I can see that many programmers probably live for this:D

seriously though, to use any non-standard library (such as allegro), I have to download it, stick it in /usr/include and then refer to it in the include section of code right?

ChriStoopha

Stoofer
11-12-2003, 04:49 PM
Thankyou evyerone!!

It works! Now I can build it inot a gargantuan temp converting program that wil convert both ways and keep asking for new data until we reach a quite statement. Heck I could make in nCurses menu based!!

(You can see where this is going!!)

Once again, thanks.

This is so you can see the joy:-

chris@slackbox:~$ jed farenheitcelcius.cpp
chris@slackbox:~$ g++ farenheitcelcius.cpp -o conv2
chris@slackbox:~$ conv2
Enter the temperature in Celcius:45
Farenheit values is:113
chris@slackbox:~$ conv2
Enter the temperature in Celcius:35
Farenheit values is:95
chris@slackbox:~$
chris@slackbox:~$ conv2
Enter the temperature in Celcius:102
Farenheit values is:215
chris@slackbox:~$ conv2
Enter the temperature in Celcius:40
Farenheit values is:104
chris@slackbox:~$ conv2
Enter the temperature in Celcius:39
Farenheit values is:102
chris@slackbox:~$