ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have compiled a program on an earlier version of Mandrake.. and it all works fine.
However, when I port the program to Mandrake 9.1, the compiler cannot compile the code that uses the fstream class. I.e. it cannot find the include files for it.
On the previous version of Mandrake there was a Gcc++ (i think) directory that held the fstream include, which does not seem to be present under Mandrake 9.1.
Does anyone have any idea how I can get this code to compile?
Or is there another class I can use instead of fstream, to get output to a file?
"However, when I port the program to Mandrake 9.1, the compiler cannot compile the code that uses the fstream class. I.e. it cannot find the include files for it."
Could you post the error messages that the compiler gives you?
From what I recall, I was using a ofstream to define a file to write to.. and the error message was something like.... "ofstream used as a type, but not defined as a type".... hence I assumed that it could not find the relevant include file.
The I searched /usr/include for fstream include file.. but on Mandrake 9.1 it was not present, where as on the previous version of Linux it was in a gcc+ directory.
Posting a bit of code would help too. Were you using <fstream> or <fstream.h>? You should be using <fstream> as <fstream.h> is deprecated. You also need to be aware that <fstream> puts everything into the std namespace, so you should use something like a "using namespace std;" line, or reference ofstream as std::ofstream.
Other possibilities are that you are using gcc to compile instead of g++. g++ is the GNU C++ compiler, gcc is the GNU C compiler.
Also, make sure you have all the necessary gcc/g++ packages installed.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.