Re: undefined references to functions when linking
- From: Ben Bacarisse <ben.usenet@xxxxxxxxx>
- Date: Wed, 13 Jun 2007 01:29:31 +0100
stenasc@xxxxxxxxx writes:
On Jun 12, 6:13 pm, "Joachim Schmitz" <nospam.j...@xxxxxxxxxxxxxxxxxx>
wrote:
<sten...@xxxxxxxxx> schrieb im Newsbeitragnews:1181667898.243965.188770@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> Hi,
In a file test1.c, in have the two functions f1 and f2. These are
declared in the header file t1.h. I want to call these functions in
another file subprog.c, which contains the function call_funcs. I have
included the header file t1.h in subprog.c. Using gcc, I can compile
and get subprog.o without any problems.
However, when I try to link subprog.o into the main application, I get
the errors
In function call_funcs undefined reference to f1
In function call_funcs undefined reference to f2
Anybody have any idea what could be causing this.
You need to compile test1.c too and link the resulting .o with the
subprog.o.
Thanks Jojo...that fixed it...I now get multiple definition
errors...you don't know how to solve that???
A wild guess: t1.h defines (rather than declares) one or more global
variables. I.e. you have "int x;" rather than "extern int x;" in
t1.h. If this is the problem, you need to use the extern form in the
..h file and ensure that only one (you get to chose) compilation unit
contains the actual definition.
--
Ben.
.
- References:
- undefined references to functions when linking
- From: stenasc
- Re: undefined references to functions when linking
- From: Joachim Schmitz
- Re: undefined references to functions when linking
- From: stenasc
- undefined references to functions when linking
- Prev by Date: Re: memset + free
- Next by Date: Re: Double linked list
- Previous by thread: Re: undefined references to functions when linking
- Next by thread: Re: undefined references to functions when linking
- Index(es):
Relevant Pages
|
|