Undefined references with multiple headers

Discussion in 'C Programming' started by smc, Dec 21, 2010.

  1. smc

    smc

    Joined:
    Dec 21, 2010
    Messages:
    2
    Hi guys,

    I have some problem to create a executable.

    I have a program test.c (which contains the main() ). This includes one 1.h where is defined the prototype of some functions (which are given by 1.c), but also this 1.h includes other 2.h where C structures are given. This code is needed for 1.c (and other modules).

    So, the gcc generates the object code without problems for 1.c ($gcc -I ../include -o 1.o -c 1.c). But when I try to generate the executable of test , I get undefined references problems. I try to create the executable as follows:

    $ gcc -I ../include -o test test.o 1.o -lm

    (In ../include are all .h)

    This fail with undefined reference to the C structures given by 2.h.

    Any idea?
     
    smc, Dec 21, 2010
    #1
    1. Advertising

  2. smc

    smc

    Joined:
    Dec 21, 2010
    Messages:
    2
    Nobody can help me?
     
    smc, Dec 22, 2010
    #2
    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. dont bother
    Replies:
    0
    Views:
    868
    dont bother
    Mar 3, 2004
  2. Phil
    Replies:
    4
    Views:
    734
    Gabriel Genellina
    Jan 17, 2010
  3. Ian
    Replies:
    2
    Views:
    2,113
  4. Clay Culver

    Rails - undefined method `headers'

    Clay Culver, Oct 25, 2005, in forum: Ruby
    Replies:
    3
    Views:
    129
    Dave Burt
    Oct 25, 2005
  5. Nomen Nescio
    Replies:
    11
    Views:
    259
    BiKiKii
    Sep 26, 2006
Loading...

Share This Page