2

I am getting following error when I add user defined method in library using turbo c linker error: undefined symbol _sum in module my.c I followed all steps properly:

 // 1. create addition.c containing function definatio and compile it

addition.c:

 addition(int i, int j)
  {
  int total;
 total = i + j;
 return total;
 }

Step 2:

Compile addition.c file by using Alt + F9 keys (in turbo C) addition.obj file would be created which is the compiled form of addition.c file.

Step 3: Add it to library using tlib

c:\> tlib math.lib + c:\ addition.obj

Means adding c:\addition.obj file in the math library.

Step 4: Created a file addition.h & declare prototype of addition() function like below.

 int addition (int i, int j);

Now addition.h file containing prototype of function addition.

# include <stdio.h>
     // Including our user defined function.
     # include “c:\\addition.h”     
   int main ()
   {
   int total;
   // calling function from library
   total = addition (10, 20); 
   printf ("Total = %d \n", total);
    }
Sam
  • 7,252
  • 16
  • 46
  • 65
user3575428
  • 21
  • 1
  • 1
  • 4
  • 4
    Using a compiler that is old enough to get a driving license in most countries seems like a bad idea... Without us seeing some of the code you are using, it's impossible to help, no matter what compiler you are using. – Mats Petersson Apr 26 '14 at 08:29
  • Plz help me to figure out this small problem. Its urgent !! – user3575428 Apr 26 '14 at 10:08

3 Answers3

1

While writtig this command you need to specify full path of Lib and your module u want to add to library. Just try it ! e.g.

Tlib d:\turboc\Lib\CS.lib + d:\turboc\demo.obj

SKabir
  • 11
  • 1
0

I tried making an project in TurboC, that option is right in the menu bar, click open, give any name, then add the sourcce code file along with the header file, it works :)

Tuesday
  • 55
  • 1
  • 7
0

It means that you have not enabled the graphics library for linking. By default this setting is OFF when you install Turbo C++ version 3.0. All you need to do is, from turbo c++ menu, goto Options -> Linker -> Libraries... and check the Graphics Library option

IshanGarg
  • 3,987
  • 4
  • 11
  • 10