# Compiling a program

**URL:** <https://community.unix.com/t/compiling-a-program/145989>\
**Category:** Programming\
**Created:** [June 16, 2003, 2:00pm UTC](https://community.unix.com/t/compiling-a-program/145989 "2003-06-16T14:00:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Minnesota\_Red](https://community.unix.com/letter_avatar/minnesota_red/32/6_449c533f586939b6e5f246632a46421f.png) [@Minnesota\_Red](https://community.unix.com/u/Minnesota_Red)\
**Post date:** [June 16, 2003, 2:00pm UTC](https://community.unix.com/t/compiling-a-program/145989/1 "2003-06-16T14:00:52Z")

</div>

Hello. I am trying to run a c program on a unix shell (ssh). I have searched this forum but have not come accross the soultion to my problem, so I am posting my question here 🆒

I wrote the following simple code:

#include \<iostream.h\>

using namespace std;

int main()  
{  
cout \<\< "\nThis is our first C++ prgram.";  
cout \<\< "\nIt works!!!";

```
    return 0;

```

}

I saved this in a file called first.c  
I entered command gcc first.c  
I get error "first.c:1: iostream.h: No such file or directory"  
I dont understand, does the gcc compiler not come with standard headers such as iostream and iomanip?

---

<div class="post-metadata">

**Author:** ![larry](https://community.unix.com/letter_avatar/larry/32/6_449c533f586939b6e5f246632a46421f.png) [@larry](https://community.unix.com/u/larry)\
**Post date:** [June 16, 2003, 2:17pm UTC](https://community.unix.com/t/compiling-a-program/145989/2 "2003-06-16T14:17:51Z")

</div>

Minnesota Red,

I'm not sure if this would solve your problem, but check your LD\_LIBRARY\_PATH. This would be different depending on your OS. It seem to me that your "env" variable may not include the system standard library path. Try \> env|grep LIBRARY, then chek each directory to see if the library is there. You may just be missing the library in general. If on a linux platform try \>locate ipstream.h. If you get a result then that mean you have some other problem.

Larry

---

<div class="post-metadata">

**Author:** ![Minnesota\_Red](https://community.unix.com/letter_avatar/minnesota_red/32/6_449c533f586939b6e5f246632a46421f.png) [@Minnesota\_Red](https://community.unix.com/u/Minnesota_Red)\
**Post date:** [June 16, 2003, 2:37pm UTC](https://community.unix.com/t/compiling-a-program/145989/3 "2003-06-16T14:37:28Z")

</div>

OS is winxp, but I am using ssh to compile. I dont know if that makes much difference. I am a newbie, so I did not follow what you were saying.

BTW, Mod can U move this to correct forum. I just realized I posted this in wrong area by accident.

---

<div class="post-metadata">

**Author:** ![RTM](https://community.unix.com/user_avatar/community.unix.com/rtm/32/58_2.png) [@RTM](https://community.unix.com/u/RTM)\
**Post date:** [June 16, 2003, 2:52pm UTC](https://community.unix.com/t/compiling-a-program/145989/4 "2003-06-16T14:52:29Z")

</div>

(Moved)

Your shell has variables set (seen with the env command). One of them is the LD\_LIBRARY\_PATH. You need to find where the file iostream.h is located and add that directory path to your LD\_LIBRARY\_PATH.

# echo $LD\_LIBRARY\_PATH  
/usr/lib:/usr/local/lib:/usr/openwin/lib

(Ours is set up in a second profile)  
# . /u/etc/profile  
Profile Rev: v1.2.0.4 Platform: SunOS Architecture: sun4u  
Initializing: ................ Done.  
#  
# echo $LD\_LIBRARY\_PATH  
LD\_LIBRARY\_PATH=/usr/local/lib:/usr/lib:/lib:/u/lib:/usr/ccs/lib:/usr/5bin/lib:/usr/ucblib:/usr/xpg4/lib:/u/lib:/usr/openwin/server/lib:/usr/openwin/lib:/usr/opt/SUNWmd/lib

> [@](#):
>
> quote from other topic  
> I am trying to run a c program on an account I have on someones debian linux based server. My c program uses iostream.h, but I get an error saying this file is not located in directory.

So the OS is Debian Linux, not WinXP - the Linux system is where you are compiling, correct?

To find the file, you can ask the Sys Admin, or try using the find command (man find) - it may be in /usr or /u (it matters how the system is set up).

> [@](#):
>
> YES, I am a n00b

And honest too.

---

<div class="post-metadata">

**Author:** ![Perderabo](https://community.unix.com/user_avatar/community.unix.com/perderabo/32/27_2.png) [@Perderabo](https://community.unix.com/u/Perderabo)\
**Post date:** [June 16, 2003, 3:28pm UTC](https://community.unix.com/t/compiling-a-program/145989/5 "2003-06-16T15:28:34Z")

</div>

You have written a c++ program, not a c program.

Try this command

g++ first.c -o first

to compile it. You have a bug, but I'll let you find it.

---

<div class="post-metadata">

**Author:** ![Minnesota\_Red](https://community.unix.com/letter_avatar/minnesota_red/32/6_449c533f586939b6e5f246632a46421f.png) [@Minnesota\_Red](https://community.unix.com/u/Minnesota_Red)\
**Post date:** [June 16, 2003, 4:13pm UTC](https://community.unix.com/t/compiling-a-program/145989/6 "2003-06-16T16:13:20Z")

</div>

u sure? this is str8 out the text book

btw, the g++ worked. THANX!

how do I go about executing the a.out that I now have?

---

<div class="post-metadata">

**Author:** ![Perderabo](https://community.unix.com/user_avatar/community.unix.com/perderabo/32/27_2.png) [@Perderabo](https://community.unix.com/u/Perderabo)\
**Post date:** [June 16, 2003, 4:29pm UTC](https://community.unix.com/t/compiling-a-program/145989/7 "2003-06-16T16:29:44Z")

</div>

Your output file is called first. You can run it with "./first".

Use your own good judgement as you view the results.

---

<div class="post-metadata">

**Author:** ![Minnesota\_Red](https://community.unix.com/letter_avatar/minnesota_red/32/6_449c533f586939b6e5f246632a46421f.png) [@Minnesota\_Red](https://community.unix.com/u/Minnesota_Red)\
**Post date:** [June 16, 2003, 4:35pm UTC](https://community.unix.com/t/compiling-a-program/145989/8 "2003-06-16T16:35:15Z")

</div>

Yah I just found that browsing another site. THANX A LOT FOR HELP. I am finally seeing how c++, with unix, with a database tie in... its all coming together.

So my college degree wasnt a total waste, was it 😃 ?
