Solved

compile error

Posted on 2000-04-21
29
281 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
ID: 2738185
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
ID: 2738665
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
ID: 2739009
try to change the line:

#include <iostream>

by this one:

#include <iostream.h>
0
 

Author Comment

by:rlivings
ID: 2739173
tried that, nope
0
 
LVL 1

Expert Comment

by:zx9r
ID: 2739216
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
ID: 2739308
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
ID: 2739586
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
ID: 2739907
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
ID: 2740075
what is the error the compiler says?
0
 

Author Comment

by:rlivings
ID: 2740213
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
ID: 2740394
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
ID: 2740550
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
ID: 2740598
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
ID: 2740610
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 40

Expert Comment

by:jlevie
ID: 2740614
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
ID: 2740625
thanks ill try that
0
 
LVL 40

Expert Comment

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

Author Comment

by:rlivings
ID: 2740763
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
ID: 2740778
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
ID: 2740862
how do i find the directory path? and the compile command is g++ test.cc
0
 
LVL 40

Expert Comment

by:jlevie
ID: 2740935
Try this from a shell window

find / -name "libstd*"

That compile command should have worked.
0
 

Author Comment

by:rlivings
ID: 2741055
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
ID: 2741166
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
ID: 2741245
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
ID: 2741264
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
ID: 2741300
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
ID: 2743519
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
ID: 2744701
so i have to check and see if i have the header files installed right?
0
 
LVL 40

Expert Comment

by:jlevie
ID: 2744801
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

867 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

21 Experts available now in Live!

Get 1:1 Help Now