The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Compiling and Running C Program on Solaris selva_ss SUN Solaris 2 02-23-2008 12:02 PM
help on compiling a C program on Tiger cleansing_flame High Level Programming 4 01-29-2008 03:59 PM
Compiling a C program ooploo High Level Programming 3 10-06-2006 06:35 AM
Problem compiling program rochitsharma High Level Programming 28 07-23-2006 08:56 PM
Error Compiling C program Vivek High Level Programming 3 10-25-2001 11:13 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-16-2003
Minnesota Red Minnesota Red is offline
Registered User
  
 

Join Date: Jun 2003
Posts: 24
Compiling a program

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?
  #2 (permalink)  
Old 06-16-2003
larry larry is offline
Registered User
  
 

Join Date: Nov 2001
Location: Hawaii
Posts: 79
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
  #3 (permalink)  
Old 06-16-2003
Minnesota Red Minnesota Red is offline
Registered User
  
 

Join Date: Jun 2003
Posts: 24
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.

Last edited by Minnesota Red; 06-16-2003 at 02:42 PM..
  #4 (permalink)  
Old 06-16-2003
RTM's Avatar
RTM RTM is offline Forum Advisor  
Hog Hunter
  
 

Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
(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:
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).
Quote:
YES, I am a n00b
And honest too.

Last edited by RTM; 06-16-2003 at 03:01 PM..
  #5 (permalink)  
Old 06-16-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
c != c++

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.
  #6 (permalink)  
Old 06-16-2003
Minnesota Red Minnesota Red is offline
Registered User
  
 

Join Date: Jun 2003
Posts: 24
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?

Last edited by Minnesota Red; 06-16-2003 at 04:21 PM..
  #7 (permalink)  
Old 06-16-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Your output file is called first. You can run it with "./first".

Use your own good judgement as you view the results.
Closed Thread

Bookmarks

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0