External function?

Sample1.c

#include "stdio.h"
int f1(int x, int y)
{
  printf("%d %d", x, y);
  return x+y;
}

Sample2.c

#include "stdio.h"
extern int f1(int x,int y);
int main(void)
{
  printf(" %d\n", f1(5,6));
  return 0;
}

I tried to compile the file Sample1.c, then Sample2.cin the Turbo C / C ++ compiler (Windows XP). It shows the following error:

Compiling Sample2.c:
Linking Sample2.exe:
Linker Error : Undefined Symbol _f1 in module Sample2.c

Can anyone help me in this regard?

+3
source share
5 answers
  • Do not use the Turbo C compiler ... it is dead.
  • You need to link both compiler objects together with one executable.
+5
source

Turbo C is really a pretty old product; You may consider updating.

C C , . Turbo C, , - .

, , , , extern. .c, , . , , - .

+3

? ?

+1

You have to compile these two and link them into the same program, is that what you did?

0
source

djgpp is a good replacement for tc

gcc dos works

0
source

Source: https://habr.com/ru/post/1713225/


All Articles