linker error: undefined symbol _sum in module my.c

喜欢而已 提交于 2020-01-04 11:10:16

问题


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);
    }

回答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




回答2:


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 :)




回答3:


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



来源:https://stackoverflow.com/questions/23308489/linker-error-undefined-symbol-sum-in-module-my-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!