Re: undefined references to functions when linking



On Jun 12, 8:55 pm, "Joachim Schmitz" <nospam.j...@xxxxxxxxxxxxxxxxxx>
wrote:
<sten...@xxxxxxxxx> schrieb im Newsbeitragnews:1181672366.203975.284250@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



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.

Bye, Jojo

Thanks Jojo...that fixed it...I now get multiple definition
errors...you don't know how to solve that???

Not without seeing the code...

Bye, Jojo- Hide quoted text -

- Show quoted text -

Hi All,

Got it sorted...had to rename a few functions and that cleared
everything up.

Many Thanks to all that replied

Bob

.



Relevant Pages

  • Re: managing header files
    ... hundred by commenting out some external declarations, ... complaints) but the complaints about redundant declarations and the complaints ... to simplify the problem I decided to just try to compile ... approach of, in effect, finding one header file that all the .c files ...
    (comp.lang.c.moderated)
  • Re: Converting .lib to .dll
    ... Adding the header file to the project does nothing. ... a DLL file. ... EXPORT_SETTING int VP_DoWhatever(int parameter1, int parameter2) ... And when you compile this, ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Parse errors
    ... Your code, shown in the previous message, will not compile with either ... NULL (which clearly indicates that it is a pointer). ... in it appropriate to a header file! ... you need prototypes for all of the functions defined in this ...
    (comp.os.linux.development.apps)
  • Re: function prototypes
    ... > the prototype and the procedure will actually agree. ... same header file in the implementation (which C ... as the header declarations can ... and compile stubs earlier than you might want, ...
    (comp.lang.fortran)
  • Re: reporting typedef errors automatically
    ... JTT> I guess it's meant to provoke the compiler to emit an error ... no it also shouldn't emit an error message for the C89 ... case since in order to compile it even in C99 mode you must ... automatically includes )- in that header file the ...
    (comp.lang.c)