Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
Distribution: Gentoo, Kubuntu, formerly LFS, SuSE, and RedHat
Posts: 133
Rep:
Compiling C++ in Linux
This application which I am trying to port to Linux was written and works fine in the Windows 95 version of DJGPP/RHIDE. I want to compile it to Linux but I can't even get a simple program to compile properly.
I used the command gcc mytest.cpp and got error messages that the function cin was not recognized.
I tried using gcc -x c++ mytest.cpp
and got error messages that the include file was deprecated.
I tried using #include <iostream> instead of iostream.h
I get confusing error messages.
there were a number of confused people on here asking about all that. it's proably down to the ISO C standards being interpreted differently by different developers... you will need to either export the standard namespace ( using namespace std; ) or clairfy the fill namespace with std::cin wherever just cin is currently used.
Basically it comes down to which compiler lags
behind the standards how far ... I believe it's a
fair bet to assume that the DOS port by Jim is
behind, since he bases on the GNU gcc suite.
If you want best compliance with C++ standards
get & use the STLPort :)
oh. Sorry for not reading through.
Why isn't g++ the solution though?
from my personal experience, gcc doesn't work and I get iostream errors, but g++ compiles perfectly.
Distribution: Gentoo, Kubuntu, formerly LFS, SuSE, and RedHat
Posts: 133
Original Poster
Rep:
This will sound kinda stupid but how do I run the program after I compile it?
I got it to compile with the gcc and g++ commands, by including the iostream.h header (even though it gave me a warning that it was deprecated) and after it had compiled the file a.out appeared in the directory. Now what do I do? Do I have to link it somehow? Sorry, but I'm used to having a development environment, not this kind of (non)interface.
Distribution: Gentoo, Kubuntu, formerly LFS, SuSE, and RedHat
Posts: 133
Original Poster
Rep:
I don't know what that little bit of code does, but it works. It lets me use the updated header so I don't get a warning message.
And as for running the app, I forgot that Linux doesn't let you type in a command right from the directory it is in. I tried the ./a.out (later I tried the filename ./practice because that's what I renamed it) and it worked fine.
Distribution: Gentoo, Kubuntu, formerly LFS, SuSE, and RedHat
Posts: 133
Original Poster
Rep:
I just realized that the first person who responded answered the question, I just didn't understand what acid_kewpie meant. Fingel clarified how to get it to work even though he might not have understood exactly what the code does (like me). Almost ironic, that those who can often best help newbies are newbies themselves.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.