Results 1 to 7 of 7

Thread: g++ help

  1. #1
    Join Date
    Jun 2005
    Beans
    42

    g++ help

    I have no clue how to get g++ to run, I am pretty sure I have all the files installed (I found an old thread), but I really have no clue how to run anything under linux. Any help on running it?

  2. #2
    Join Date
    Jan 2005
    Location
    Illinois USA
    Beans
    1,048

    Re: g++ help

    What are you trying to do? Normally, you open a terminal
    Code:
    g++ FILENAME.cpp -o BINNAME
    CloudRck.com - Host on CloudRck
    I sponsor open source projects and support users of such technologies. PM for details

  3. #3
    Join Date
    Jun 2005
    Beans
    42

    Re: g++ help

    Quote Originally Posted by DJ_Max
    What are you trying to do? Normally, you open a terminal
    thanks but I got an error

    Code:
    jared@ubuntu:~$ g++ /home/jared/Desktop/firtprogram.cpp -o BINNAME
    In file included from /usr/include/c++/3.3/backward/iostream.h:31,
                     from /home/jared/Desktop/firtprogram.cpp:3:
    /usr/include/c++/3.3/backward/backward_warning.h:32:2: warning: #warning This fi le includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples in clude substituting the <X> header for the <X.h> header for C++ includes, or <sst ream> instead of the deprecated header <strstream.h>. To disable this warning us e -Wno-deprecated.
    jared@ubuntu:~$
    when running
    Code:
    // my first program in C++
    
    #include <iostream.h>
    
    int main ()
    {
      cout << "Hello World!";
      return 0;
    }
    do you know what that means?
    Last edited by jarg; August 6th, 2005 at 02:58 PM.

  4. #4
    Join Date
    Oct 2004
    Location
    Pennsylvania
    Beans
    1,698

    Re: g++ help

    Quote Originally Posted by jarg
    Code:
    // my first program in C++
    
    #include <iostream.h>
    
    int main ()
    {
      cout << "Hello World!";
      return 0;
    }
    Try:
    Code:
    // my first program in C++
    
    #include <iostream>
    
    int main ()
    {
      std::cout << "Hello World!";
      return 0;
    }
    It looks like you just got a warning for using the old-style C++ headers. At the present, the C++ standard library uses "<foo>" includes where you see "<foo.h>" in older references. The namespace (std) is also important once you start using the new headers.

  5. #5
    Join Date
    Jan 2005
    Location
    Illinois USA
    Beans
    1,048

    Re: g++ help

    To add to what cwaldbieser said. He means adding
    Code:
     using namespace std;
    CloudRck.com - Host on CloudRck
    I sponsor open source projects and support users of such technologies. PM for details

  6. #6
    Join Date
    Oct 2004
    Location
    Pennsylvania
    Beans
    1,698

    Re: g++ help

    Quote Originally Posted by DJ_Max
    To add to what cwaldbieser said. He means adding
    Code:
     using namespace std;
    For toy programs, the [using] directive is OK. But once you start writing more complicated programs, it becomes better practice to forgo the [using] directive and just qualify your symbols. Especially in header files that you expect someone else to include. Otherwise, you just end up polluting the namespace.

  7. #7
    Join Date
    Nov 2004
    Beans
    2,614

    Re: g++ help

    Or, qualify your symbols on a per-symbol basis, at the smallest reasonable scope (usually function-scope):
    Code:
    #include <iostream>
    
    int main() {
        using std::cout;
        using std::endl;
    
        cout << "Hello World" << endl;
    }

Bookmarks

Posting Permissions

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