Find the answer to your Linux question:
Results 1 to 8 of 8
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    compiler problem

    Hi I am kind of new to Linux and these forums. I have a problem regarding g++ (gcc) utility. I was testing a simple hello world programme that compiles well under windows (borland Cpp compiler) but not under Linux the compiler complains that iostream.h is depriciated and to use iostream instead I tried this option and programme dose not recognise cout here is my source code

    #include <iostream.h>
    int main(int argc, char **argv)
    cout << "Hello World";
    return 0;

    and I get the following error message

    [wiraj@x1-6-00-09-6b-40-03-e7 Qt]$ g++ hello1.cpp
    In file included from /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.1/../../../../include/c++/3.4.1/backward/iostream.h:31,
    from hello1.cpp:1:
    /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.1/../../../../include/c++/3.4.1/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.

    A final note I am not sure if this is related or not but I have been having trouble compiling binaries downloaded as tar.gz files in my system. The make utility points me to some strange syntax errors in the code I am using gcc version 3.4.1 with mandrake 10.1

  2. #2
    Linux Guru fingal's Avatar
    Join Date
    Jul 2003
    Birmingham - UK
    Hi - Read this.
    I am always doing that which I can not do, in order that I may learn how to do it. - Pablo Picasso

  3. #3
    Oh that's a useful answer, please guys just tell me what's wrong with this. what am I doing wrong

  4. $spacer_open
  5. #4
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Seattle, WA, USA
    Quote Originally Posted by wirajR
    Oh that's a useful answer, please guys just tell me what's wrong with this. what am I doing wrong
    Yes, it is a useful answer. It shows exactly how to correct your problem.

    The problem with your code is that you are using <iostream.h>, which is a deprecated header file. Instead, you should use #include <iostream>.

    As you note, you get an error. Had you read the link that you were given, you would have noticed the line "using namespace std".

    #include <iostream> gives access to cout, cin, and endl, all of which are in the "std" namespace. You may either incorporate the entire std namespace into your own program ("using namespace std"), or you may invoke each of these by their full name ("std::cout", "std::cin", "std::endl").

  6. #5
    Oh thank you very much sir. I totally missed the link above, I am new to these forums and not used to the way it works .

  7. #6
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    I totally missed the link above...
    Actually, one of the few things I dislike about the forum facelift is the formatting for links that are posted here. I am from a school that says links should underlined. As it is, they're neither underlined nor emphasized sufficiently.

    This thread is a perfect case in point: fingal posts a good answer, but it appears (because of the way links appear here) that he is telling the OP to read his signature, which of course makes no sense in this context.

  8. #7
    Linux User Game master pro's Avatar
    Join Date
    Sep 2005
    Tasmania, australia
    I would actually recomend programming in the C language instead of C++, as C++ is a lot harder

  9. #8
    Thanks for your advice but I am more comfortable with OO. I am a Java programmer with 5 years experience and using only C would deny me most of the Java like features I am used to.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts