Undefined references with multiple headers

smc

Joined
Dec 21, 2010
Messages
2
Reaction score
0
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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top