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'm new to linux and new to C++ programming. i'm used to Borland C++ 5, Bloodshed's Dev-C on Windows platform.
I have RH 9 and going to install Slack. i have Anjuta for C++ on RH 9. the problem i have is withthe header files of C++; i used to use "iostream, stdio and conio " etc in Windows tools. but when itried using isostream, for example, in the linux (dev tool is Anjuta, and even gcc), i get errors not finding "iostream/iostream.h" . where are those header files ?where have they gone (orthey are still right under my nose but couldn't find'em)?
1. how do i use the header files in linux development tools?
2. is there any document which tells me what all header files are and how to use them in linux?
3. and what other IDEs are available in linux, which are easy to use for newbie programmers/
Ok...I'm a slack user, but gcc oughta be the same either way, so:...
gcc likes you to include the C++ headers, not the C headers, ie #include <iostream> not <iostream.h> and soforth, although I don't think this is your problem. 'cause you said you tried both anyway.
and if you're compiling a c++ program, the command would be g++, not gcc, so it'd be like this:
g++ -o ./myprog ./myprog.cpp
and if you're using some wierd library, it might require extra optiony dealies on the end of the g++ cmd dealy. Like alsa likes you to do g++ -o ./prog ./prog.cpp -lalsa (methinks this is right, although I might be thinking of allegro.)
On the IDEs:...
Mostly with Linux, you'll just use a text editor, and save your file as camelprogram.cpp or whatever, and then compile it in the shell with gcc or g++. For text editors w/ good syntax hilighting, I'd try Nedit.
There's also KWrite's cpp editor dealy, which should already be on your comp, but it seems like hte syntax hilighting only works like half the time. Although I never bothered to try to correct this in any way.
Last edited by CamelofCamelot; 12-21-2003 at 10:09 PM.
The power of gcc is that it's the allmost the same all over
Instead of
#include "iostream/iostream.h"
Use
#include <iostream>
Header files are mostly the same, except there is no .h usually. It's because the ANSI C++ standard changed a few years ago, and Windows isn't up to date.
There are a few IDEs, eclipse, anjuta, kdevelop I think are the more advanced ones.
Of course there is emacs, xemacs, vi, but those take some getting used to.
It's because the ANSI C++ standard changed a few years ago, and Windows isn't up to date.
Ummm... Yeah.... The problem with this statement is that:
1) The OS has absolutely nothing to do with what headers are included with your compiler.
2) Most of the major Windows compilers do allow for the new C++ header standards. (Including Visual C++ 6.0 and above, Borland C++ Builder, Cygwin, etc.)
Sorry about that,
The only compiler I've ever used on Windows was .. VC, so I automatically associated everyhting with it. When I used it, it wouldn't allow for the new headers at all.
No problem, It must have been an older version of VC then. 6.0 and .Net both allow the new headers. It's been a long time since I used 5.0 so that maybe didn't, but that's going back far enough that it possibly pre-dates the new ANSI standard, or came out not long after it was established.
I know Turbo C++ didn't allow the new headers, but that is REALLY getting old.
I really want a copy of the ANSI standard right now. I'm curious as to who is breaking it, gcc or VC. One of them is doing ugly things to it, I'm biased twoards saying it's VC, so I want to look it up.
I have to find a copy of it, they only sell hardcopies.. for money.
Umm... if you are still talking about the new header standards, the following compiles and works fine with g++, VC++ 6.0 and VC++ .Net...
Code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
None of the compilers I mentioned breaks that standard...
Also, I was at TechEd this last summer, and one of the things that MS was real proud of was the fact that their 2003 version of VC++ .Net is somewhere around 97% ANSI compliant, whereas g++ was around 96%, and VC++ was 70-something%. I forget the exact numbers, or the website of the group who had performed the tests, but I think it was something like that.
Granted, it was Microsoft saying this, so you need to take it with a grain of salt, but still... They did actually make some progress towards making their latest compiler more ANSI compliant.
Also, just for reference, there is a link to the C++ ANSI standards that you can look at Here
I don't think any compiler FULLY adheres to the ANSI standards, and I never claimed they did. For the header example noted here, though, most current compilers do comply...
Also, In your scoping example for VC++.... That is one of the things they fixed in the .Net version of VC++. That was one of the annoying things to me about writing code for VC++ 6.0 and the gnu compiler. You had to define it outside the for loop in order to use the same variable in 2 separate for loops. I was glad that was fixed.
Actually, I should qualify the above statement about the scoping. It still doesn't FULLY comply with that standard. For instance, you can do this in both the 6.0 and .Net versions of VC++:
Code:
for (int i=0;i<10;i++)
{
cout << i << endl;
}
cout << i << endl;
However, the following code will give you an error in VC++ 6.0 and not .Net. (Variable already defined or some such...)
Code:
for (int i=0;i<10;i++)
{
cout << i << endl;
}
for (int i=0;i<10;i++)
{
cout << i << endl;
}
That's not very good code. There are dozens of ways to do that without resorting to thigns like that. There are very good reasons why it goes out of scope, most importantly to allow us to reuse things like i, which simply aren't descriptive enough to be reused. I don't think I've ever encountered a problem in any programming language similar to this one that couldn't easily be solved in a better way. Go ANSI!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.