Re: help with old source code from book

Discussion in 'C Programming' started by Mug, Aug 1, 2009.

  1. Mug

    Mug Guest

    On Aug 1, 1:08 am, (Gordon Burditt) wrote:
    > >$ gcc LIST2_1.C iplib.c
    > >LIST2_1.C: In function `int main(int, char**)':
    > >LIST2_1.C:54: warning: converting to `int' from `double'
    > >/tmp/ccIpyCSo.o(.text+0x5f): In function `main':
    > >: warning: the `gets' function is dangerous and should not be used.

    >
    > Yes, everyone knows that, but leave gets() calls alone until you can
    > get the whole thing to compile.
    >
    > >/tmp/ccIpyCSo.o(.text+0xae): In function `main':
    > >: undefined reference to `read_pnm(char*, int*, int*, int*)'
    > >/tmp/ccIpyCSo.o(.text+0x21c): In function `main':
    > >: undefined reference to `write_pnm(unsigned char*, char*, int, int, int)'

    >
    > If you are going to compile less than the whole program at once,
    > you need to use "gcc -c" and then link all the object files together.
    > Or link with the appropriate library containing these functions.
    >


    well i do with gcc -c on iplib.c then link the .o file compile with
    LIST2_1.C but it just doesn't work


    > read_pnm() and write_pnm() aren't supplied by C, but are part of
    > the graphics package you are compiling (I recognize it as 'netpbm',
    > although it has been distributed under different names at various
    > times).
    >
    > >/tmp/ccIpyCSo.o(.eh_frame+0x11): undefined reference to
    > >`__gxx_personality_v0'
    > >collect2: ld returned 1 exit status

    >
    > Are you sure you are compiling as C, rather than C++?

    i'm compile with gcc, i found a solution not so elegent,i just put the
    main fonction in LIST2_1.C into iplib.c
    it work,it compiled all right,but it still intrigue me with it dosen't
    work on seperate
    Mug
    Mug, Aug 1, 2009
    #1
    1. Advertising

  2. Mug

    Mug Guest

    On Aug 1, 1:15 am, Mug <> wrote:
    > On Aug 1, 1:08 am, (Gordon Burditt) wrote:
    >
    >
    >
    > > >$ gcc LIST2_1.C iplib.c
    > > >LIST2_1.C: In function `int main(int, char**)':
    > > >LIST2_1.C:54: warning: converting to `int' from `double'
    > > >/tmp/ccIpyCSo.o(.text+0x5f): In function `main':
    > > >: warning: the `gets' function is dangerous and should not be used.

    >
    > > Yes, everyone knows that, but leave gets() calls alone until you can
    > > get the whole thing to compile.

    >
    > > >/tmp/ccIpyCSo.o(.text+0xae): In function `main':
    > > >: undefined reference to `read_pnm(char*, int*, int*, int*)'
    > > >/tmp/ccIpyCSo.o(.text+0x21c): In function `main':
    > > >: undefined reference to `write_pnm(unsigned char*, char*, int, int, int)'

    >
    > > If you are going to compile less than the whole program at once,
    > > you need to use "gcc -c" and then link all the object files together.
    > > Or link with the appropriate library containing these functions.

    >
    > well i do with gcc -c  on iplib.c then link the .o file compile with
    > LIST2_1.C but it just doesn't work
    >
    > > read_pnm() and write_pnm() aren't supplied by C, but are part of
    > > the graphics package you are compiling (I recognize it as 'netpbm',
    > > although it has been distributed under different names at various
    > > times).

    >
    > > >/tmp/ccIpyCSo.o(.eh_frame+0x11): undefined reference to
    > > >`__gxx_personality_v0'
    > > >collect2: ld returned 1 exit status

    >
    > > Are you sure you are compiling as C, rather than C++?

    >
    > i'm compile with gcc, i found a solution not so elegent,i just put the
    > main fonction in LIST2_1.C into iplib.c
    > it work,it compiled all right,but it still intrigue me with it dosen't


    ah i get it,well you need just change LIST1_2.C to LIST1_2.c then it's
    all right compile seperately
    seems gcc complain with .C.

    zsh/3 1713 % gcc iplib.c LIST2_1.c
    /tmp/ccmxpnPd.o: In function `main':
    LIST2_1.c:(.text+0x61): warning: the `gets' function is dangerous and
    should not be used.

    > work on seperate
    > Mug
    Mug, Aug 1, 2009
    #2
    1. Advertising

  3. Mug

    Nobody Guest

    On Fri, 31 Jul 2009 18:19:16 -0700, Mug wrote:

    > ah i get it,well you need just change LIST1_2.C to LIST1_2.c then it's
    > all right compile seperately
    > seems gcc complain with .C.


    ..C (upper-case) is the historical extension for C++ source files on Unix
    (I'm sure that they did that just to annoy DOS users).

    So gcc compiles .C files using the C++ compiler, but it won't link against
    the C++ run-time library without being explicitly told to.
    Nobody, Aug 1, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Hill
    Replies:
    3
    Views:
    389
    Jim Hill
    Feb 12, 2007
  2. *Prot3anThr3ad*

    old repository for old C++ source code

    *Prot3anThr3ad*, Sep 29, 2006, in forum: C++
    Replies:
    6
    Views:
    365
    *Prot3anThr3ad*
    Oct 2, 2006
  3. John Henry
    Replies:
    24
    Views:
    993
    alex23
    May 30, 2008
  4. Mug
    Replies:
    4
    Views:
    391
    Beej Jorgensen
    Aug 1, 2009
  5. Phil Carmody

    Re: [LONG] help with old source code from book

    Phil Carmody, Aug 3, 2009, in forum: C Programming
    Replies:
    2
    Views:
    332
    Phil Carmody
    Aug 3, 2009
Loading...

Share This Page