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

Simple2.c
------------------------------------

#include<stdio.h>

extern int f1(int x,int y);
void main()
{
printf(" %d\n", f1(5,6));
}
-----------------------------------

I was trying complie Simple1.c file then Simple2.c on Turbo C/C++ Compiler (Windows Xp). It showing following error :
Compiling Sample2.c :
Linking Sample2.exe:
Linker Error : Undefined Symbol _f1 in module Sample2.c

Can any body help me regards this.
my mail id is : <snipped>

That would happen if you do this:

C:\> tcc Sample1.c
C:\> tcc Sample2.c

The linker errors because those two calls to tcc are separate. They both try to compile and link the file, but there is no definition of f1 when compiling and linking just Sample2.c. To get the definition, you need to be able to link Sample1.c to Sample2.c. To do both at once and link them together, you do it with one call:

C:\> tcc Sample1.c Sample2.c

Or you compile the Sample1.c to an object file and link it with the object file of Sample2.c, but it is not as convenient as doing it all in one line:

C:\> tcc -c Sample1.c
C:\> tcc Sample2.c Sample1.obj

or

C:\> tcc -c Sample1.c
C:\> tcc -c Sample2.c
C:\> tcc Sample1.obj Sample2.obj

Please excuse any mistakes, I am going on memory of Turbo C. ;)

Before someone else attacks you about your choice of compiler, Turbo C/C++ is very old. There are better options now, like Code::Blocks or Visual C++ Express. Newer compilers make better use of recent improvements in CPUs and compiler design, and your code can only benefit from those improvements. :)

Also, if you want to move from C to C++, a compiler released after 1998 is a must because that is when C++ was standardized. If you use Turbo C++, you will miss out on most of the best stuff from standard C++.

commented: attack thwarted +14

Thanks for your valuable time & reply....

I tried this but it shows error:
Error Sample1.c : Unable to open include file 'stdio.h'

Error Sample1.c : Unable to open include file 'stdio.h'

stdio.h is a header that comes with the compiler. Either the configuration for the compiler is wrong, or the installation is corrupted if it cannot find a standard header file. Have you been able to compile and run programs with this installation of Turbo C before?

compile with -I option
like
tcc -I /tc/include(full include directory path) test.c

I tried with following option :
tcc -I /tc/include(full include directory path) test.c

But still 'stdio.h' file not able to open.

1)locate the path where you have your c installation.
e.g its in C:\tc
2)go to c:\tc\include and check stdio.h is present or not.

then compile like this

tcc -I c:\tc\include -L c:\tc\lib <yourfile.c>

it will never show errors.Do it properly and show the the output log in case of any further issues.

one more thing can you able to compile you code form TC editor.using compile option??
anyways these two are no way related. you try both -I and -L it will work.
Thanks,
DP

Now Please tell :
My TC on E:\

My programs stored on

E:\TC\Simple1.c
E:\TC\Simple2.c

And tcc.exe & TC.exe is on

E:\TC\BIN\

Now please tell me how I should give command.

ensure that you have include and lib folders as per the path and
check for stdio.h file maually once.
then compile like this

tcc -I e:\tc\include -L e:\tc\lib test.c

I tried with following command :

E:\TC\BIN> tcc -I e:\tc\include -L e:\tc\lib A.c

But it showing error "Incorrect command line option: -L

my gmail id is : tatyakadamlove

Prev, is wrong

my gmail id is : tatyakadamlove143

tcc -Ie:\tc\include test.c

try this only...

note: type 'tcc' to see all supported options by tcc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.