compile problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • luke.yolanda@gmail.com

    #1

    compile problem

    I write a simple problem ,as:

    *************** ***************
    //temp.cpp
    #include<iostre am.h>

    int main(void){
    cout<<"12313123 1";
    return 0;
    }
    *************** **************


    and when I type "gcc -o temp temp.cpp", it shows:

    *************** *************** *
    In file included from /usr/include/c++/4.0.2/backward/iostream.h:31,
    from temp.cpp:1:
    /usr/include/c++/4.0.2/backward/backward_warnin g.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
    17.4.1.2 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.
    /tmp/cc2wKN3t.o: In function `main':
    temp.cpp:(.text +0x25): undefined reference to `std::cout'
    temp.cpp:(.text +0x2a): undefined reference to `std::basic_ost ream<char,
    std::char_trait s<char> >& std::operator<< <std::char_trai ts<char>[color=blue]
    >(std::basic_os tream<char, std::char_trait s<char> >&, char const*)'[/color]
    /tmp/cc2wKN3t.o: In function `__tcf_0':
    temp.cpp:(.text +0x47): undefined reference to
    `std::ios_base: :Init::~Init()'
    /tmp/cc2wKN3t.o: In function
    `__static_initi alization_and_d estruction_0(in t, int)':
    temp.cpp:(.text +0x74): undefined reference to
    `std::ios_base: :Init::Init()'
    /tmp/cc2wKN3t.o:(.eh _frame+0x11): undefined reference to
    `__gxx_personal ity_v0'
    collect2: ld returned 1 exit status

    *************** *************** *

    Could anyone tell me what teh problem is?

  • Robert Gamble

    #2
    Re: compile problem

    luke.yolanda@gm ail.com wrote:[color=blue]
    > I write a simple problem ,as:
    >
    > *************** ***************
    > //temp.cpp
    > #include<iostre am.h>[/color]

    Stop right there. The space goes *after* the comma.
    And oh yeah, we don't discuss that C++ stuff here, different language,
    different group, try comp.lang.c++.

    Robert Gamble

    Comment

    • Keith Thompson

      #3
      Re: compile problem

      "luke.yolanda@g mail.com" <luke.yolanda@g mail.com> writes:[color=blue]
      > I write a simple problem ,as:
      >
      > *************** ***************
      > //temp.cpp
      > #include<iostre am.h>
      >
      > int main(void){
      > cout<<"12313123 1";
      > return 0;
      > }
      > *************** **************[/color]

      This is C++, not C. I'd tell you to post to comp.lang.c++, but ...
      [color=blue]
      > and when I type "gcc -o temp temp.cpp", it shows:
      >
      > *************** *************** *[/color]
      [snip][color=blue]
      > /tmp/cc2wKN3t.o: In function `main':
      > temp.cpp:(.text +0x25): undefined reference to `std::cout'[/color]
      [snip]

      it's a problem with your compilation environment, not with the
      language. Try gnu.gcc.help.

      --
      Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
      San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
      We must do something. This is something. Therefore, we must do this.

      Comment

      • santosh

        #4
        Re: compile problem

        luke.yolanda@gm ail.com wrote:[color=blue]
        > I write a simple problem ,as:
        >
        > *************** ***************
        > //temp.cpp
        > #include<iostre am.h>
        >
        > int main(void){
        > cout<<"12313123 1";
        > return 0;
        > }
        > *************** **************
        >
        >
        > and when I type "gcc -o temp temp.cpp", it shows:[/color]

        Just a wild guess, but why not try with the 'g++' command instead.
        (Under DOS i.e. DJGPP, it is 'gpp')

        For further C++ questions, please post to a C++ newsgroup like
        comp.lang.c++ or alt.comp.lang.l earn.c-c++ etc.

        Comment

        • John Bode

          #5
          Re: compile problem


          Cross-posted to comp.lang.c++, followups set to comp.lang.c++.

          luke.yolanda@gm ail.com wrote:[color=blue]
          > I write a simple problem ,as:
          >
          > *************** ***************
          > //temp.cpp
          > #include<iostre am.h>
          >
          > int main(void){
          > cout<<"12313123 1";
          > return 0;
          > }
          > *************** **************
          >
          >
          > and when I type "gcc -o temp temp.cpp", it shows:
          >
          > *************** *************** *
          > In file included from /usr/include/c++/4.0.2/backward/iostream.h:31,
          > from temp.cpp:1:
          > /usr/include/c++/4.0.2/backward/backward_warnin g.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
          > 17.4.1.2 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.
          > /tmp/cc2wKN3t.o: In function `main':
          > temp.cpp:(.text +0x25): undefined reference to `std::cout'
          > temp.cpp:(.text +0x2a): undefined reference to `std::basic_ost ream<char,
          > std::char_trait s<char> >& std::operator<< <std::char_trai ts<char>[color=green]
          > >(std::basic_os tream<char, std::char_trait s<char> >&, char const*)'[/color]
          > /tmp/cc2wKN3t.o: In function `__tcf_0':
          > temp.cpp:(.text +0x47): undefined reference to
          > `std::ios_base: :Init::~Init()'
          > /tmp/cc2wKN3t.o: In function
          > `__static_initi alization_and_d estruction_0(in t, int)':
          > temp.cpp:(.text +0x74): undefined reference to
          > `std::ios_base: :Init::Init()'
          > /tmp/cc2wKN3t.o:(.eh _frame+0x11): undefined reference to
          > `__gxx_personal ity_v0'
          > collect2: ld returned 1 exit status
          >
          > *************** *************** *
          >
          > Could anyone tell me what teh problem is?[/color]

          Change iostream.h to just iostream, and either change cout to std::cout
          or use a using clause:

          #include <iostream>

          int main(void)
          {
          std::cout << "123131231" << std::endl; // wouldn't hurt to throw an
          EOL in here
          return 0;
          }

          or

          #include <iostream>

          using std::cout;
          using std::endl;

          int main(void)
          {
          cout << "123131231" << endl;
          }

          Comment

          Working...