Solved

compile error

Posted on 2000-04-21
29
280 Views
Last Modified: 2010-04-22
I keep getting the error-
  no such file or directory
-concerning my iostream when i try to compile my c program.  Ive tried using std namesake and declaring iostream as a header file but still no luck.  Im pretty sure the libraries are installed
0
Comment
Question by:rlivings
  • 13
  • 11
  • 4
  • +1
29 Comments
 
LVL 2

Expert Comment

by:munsie
Comment Utility
are you using g++ to compile (vs. gcc)?

iostream is a c++ feature, not c.  also, make sure your filename extension is .cpp (or one of the various C++ extensions).

good luck,
dennis
0
 

Author Comment

by:rlivings
Comment Utility
this is my program
#include <iostream>

using namespace std;

int main()
{
  cout << "hello";
  return 0;
}

ive tried compiling with gcc and g++, the filename extension is .cc and it still does not work
0
 
LVL 1

Expert Comment

by:zx9r
Comment Utility
try to change the line:

#include <iostream>

by this one:

#include <iostream.h>
0
 

Author Comment

by:rlivings
Comment Utility
tried that, nope
0
 
LVL 1

Expert Comment

by:zx9r
Comment Utility
write the following code and compile it with g++:

#include <iostream.h>

using namespace std;

int main()
{
       cout << "hello";
       return 0;
}


if it doesn´t work then you have to install de desired library
0
 

Author Comment

by:rlivings
Comment Utility
doesnt work zx9r, i guess i dont have the libraries installed.  someone posted a similar question recently and i checked to see if it was that using kpackage? im pretty sure i had it installed.  Ill try again thanks
0
 

Author Comment

by:rlivings
Comment Utility
I know i have the libraries for c and c++ files installed yet it still isnt recognized.   help anyone
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
What Linux are you using and which compiler do you have? You can check the compiler with "cc -v".
0
 
LVL 1

Expert Comment

by:zx9r
Comment Utility
what is the error the compiler says?
0
 

Author Comment

by:rlivings
Comment Utility
my error is no such file or directory found (concering the iostream).  I am also using mandrake p-gcc and p-gcc-c++ I think it is called and i am not sure how to check the compiler using "cc -v".  Sorry, im really green i have experience as a user but installation and so forth , nada
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
p-gcc/p-gcc-c++??? I don't use Mandrake, but those don't sound like a C or C++ compiler. I think you might not actually have a valid C/C++ development environment installed. Does "gcc -v" work and produce a version string? If that doesn't work either, try "rpm -q gcc". Looking at a Mandrake ftp site I can see that the distro includes gcc-2.95.2/gcc-c++-2.95.2 and if those are installed gcc ought to be how you'd invoke the compiler.
0
 

Author Comment

by:rlivings
Comment Utility
jlevie, i tried using the rpm -q gcc and it said package gcc is not installed.  I thought otherwise when i checked for the compilers using kpackage. Would you know how i could install them?
0
 
LVL 1

Expert Comment

by:zx9r
Comment Utility
como me parece que entiendes mejor el castellano, pues eso, te contestare en castellano :

a ver, lo primero es saber el nombre del paquete que quieres instalar, si no lo sabes puedes buscarlo con un ls *gcc* y mira los paquetes que hay.
Esto lo haces en el directorio donde estan todos los rpms (normalmente en el cd en RedHat/RPMS

luego lo instalas con rpm -iv paquete_que_quieres_instalar
0
 
LVL 40

Accepted Solution

by:
jlevie earned 50 total points
Comment Utility
I think I might have an idea or two...

On your Mandrake installation CD I believe you'll find:

gcc-2.95.2-3mdk.i586.rpm
gcc-c++-2.95.2-3mdk.i586.rpm
gcc-cpp-2.95.2-3mdk.i586.rpm
libstdc++-2.95.2-3mdk.i586.rpm  

and some other gcc-* rpms. Since I don't use Mandrake I can't tell if there are other things that you'll need in addition to those (rpm/kpackage will tell you if they depend on others you've not installed). If not installed, you'll almost certainly want to add make-3.77-11mdk.i586.rpm to the list.

The easiest way to add them is with kpackage. Taking note of any that fail the dependancies check (and installing the dependant packages), then installing the package. You could also install them from the command line with "rpm -ivh /path-to/some.rpm", but kpackage will let you look at the description of what the package provides. That's helpful if you are trying to decide if you need it.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 40

Expert Comment

by:jlevie
Comment Utility
I guess I shouldn't assume that you are using Mandrake 7.0. If it's an earlier version the exact version might be different. I'm looking at a Mandrake 7.0 ftp site for the package names.
0
 

Author Comment

by:rlivings
Comment Utility
thanks ill try that
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
If you run into problems, post a comment here and I'll do what I can to help.
0
 

Author Comment

by:rlivings
Comment Utility
alright ive tried compiling a c program and i have no problem compiling and running it, but when it comes to c++ it cant find the iostream file.  Ive looked and i see the c libraries in the system environment? folder but the c++ libraries are in their own folder in a different location. maybe that is the problem?

Ron
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
That seems odd, I would expect them to be in /usr/lib along with all of the other libraries. What exact compile command did you use and what's the directory path to libstdc++* files?
0
 

Author Comment

by:rlivings
Comment Utility
how do i find the directory path? and the compile command is g++ test.cc
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
Try this from a shell window

find / -name "libstd*"

That compile command should have worked.
0
 

Author Comment

by:rlivings
Comment Utility
used the statement but it said file not found or something like that.   Using the xwindow i looked in the rpm package and in the submenu called development there is the c++ file which does not include c++ libraries but there is another submenu called libraries which has libstdc++.  Im thinking maybe i have to move the file or something i dont know.  thanks for your help anyway
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
See if you've installed the libstdc++ libs with "rpm -q libstdc++". If they aren't yet installed you'll need to add that package. Also if they've been installed they should be in /usr/lib, check by "ls /usr/lib/libstdc++*".
0
 

Author Comment

by:rlivings
Comment Utility
alright jlevie tried to check and this is the output-
    /usr/lib/libstdc++ -libc6.1-1.so.2@
    /usr/lib/libstdc++.so.2.7.2@
    /usr/lib/libstdc++.so.2.7.2.8*
    /usr/lib/libstdc++.so.2.8@
    /usr/lib/libstdc++.so.2.8.0*
    /usr/lib/libstdc++.so.2.9@
    /usr/lib/libstdc++.so.2.9.0*
- which i assume means i have the libraries installed of course when i use the code way on the top, i still get the same error.  I was thinking about installing it again using GNOME RPM, but when i install the library it says failed to open /var/lib/rpm/packages.rpm
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
You've got the libs installed, so it has to be something else. Make sure that your C++ file test.cc looks exactly like:

#include <iostream.h>

using namespace std;

int main()
{
    cout << "hello";
    return 0;
}

and compile it with the command:

g++ -o test test.cc

Copy everything that you see on the screen when you compile (including the compile command) into a comment so that I can see it, please.
0
 

Author Comment

by:rlivings
Comment Utility
okay i copied everything above in my test file and here is my prompt and commands:
[rlivings@localhost~]$g++ -o test test.cc

//the error is this:
test.cc:3:iostream.h: no such file or directory


that is it (the above is supposed to be on one line each but does not fit)
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
Okay, now the problem is that the header files seem to be absent. I would have thought that they'd have been installed along with the compilers, but maybe not. On my Redhat system, iostream.h is in /usr/include/g++-2. The g++ compiler knows to look there for c++ headers.
0
 

Author Comment

by:rlivings
Comment Utility
so i have to check and see if i have the header files installed right?
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
Yep. As I said, on Linux I'd normally expect to find them in /usr/include or one of it's sub-directories.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now