473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Linker error undefined function Plzzz solve it

i use turbo c++ v3.0.
i tried to create a library and add the following
functions to it.
int prime(int);
long fact(long);
i used the standard procedure for doing so.
yet when i tried to use my functions after
including the header file i had created, a linker
error occured.
linker error : undefined symbol fact(long) in
module noname00.cpp.
now i had used 'int' in my program which means
that it had identified the function in my library, yet
it refused to work.
is it because my compiler is outdated or because
of some other flaw in the program.
for the record i had applied the procedure as
stated in yashwant kanetkar's book 'Let Us C'.
please advise on how to correctly create a user
defined library.
plzzz show with a example
Apr 30 '15 #1
6 1889
weaknessforcats
9,208 Expert Mod 8TB
Is this a static or dynamic library? That is, is it a .lib or a dll?

If it is a .lib, have you added the library name to the build of your program? The library name needs to be there as a linker resource.
Apr 30 '15 #2
no I have not added
I just added the filename , but this is a file inclusion example but I want to do by library method
In the header section I typed
#include<studio.h>
#include<conio.h>
#include "filename.h"
May 1 '15 #3
Sir please give all syntaxes with any name as a example
I m really confused plzz help me
May 1 '15 #4
How to add Library file name in the program
I typed #include "func.lib"
but it was reported as error as cannot open the specified file
so what to do
May 1 '15 #5
I don't know the specifics of the IDE you are using. However, regardless of whether func.lib is a static library or an implementation library, there has to be a place in the linker's settings for adding the location on disk (path) of the func.lib file. Furthermore, there has to be another setting for specifying linker flags or linker include libraries. You will type func in this setting (I know you do not need to specify the .lib part for gcc). Often times, the linker settings are found bundled with the compiler settings in many IDEs. I would appreciate it if someone posts the specific instructions for turbo c++. Alternatively, you can create a small Makefile for your project that includes the LDFLAG and feed it to gcc through make.

Why is it that you are experiencing this issue? Well, the #include directive is only used for header files. The way the traditional compilation process work is that you write some code, let's say in test.cc. Then, you feed this code file to a compiler, such as g++. The compiler doesn't need to know whether func.lib exists. Instead, it just needs to know the type return by the function you invoke and the number of arguments and their types in such function. At this stage, the compiler finds this information in func.h, which is the header file where you declared int prime(int) and long fact(long). The compiler spews out the machine-code representation of what you wrote and calls the linker. The linker is a program that works like a sort of book assembler. Each machine-code representation (.o, .obj, .lib, and .a files) are similar to book chapters. The linker starts sticking the code you wrote(which is now in the form of .o) together in order to produce the book called YourProgram (which is of the form .exe if working in a Windows environment). However, once in a while, it will find references to chapters you did not wrote or you wrote separately (func.lib) and it won't know what to do. If you specified the filepath to func.lib in your settings, it will be the same as if you told the linker, "Look, the chapter of the book you are desperately looking for is in this other book. Please, make a copy of it and stick it into the book you are currently assembling!" That's what the compiler does. Its product is the working program you can then run! I hope this analogy clarifies the process and gives you a hint as to what you must find in the compiler's/ linker's setting feature of your IDE. Maybe, try googling for "turbo c++ linker settings menu"? Cheers!

P.S. I forgot to say that the #include directive actually tells the compiler to call another program that searches for the header file (technically speaking a text file) you specify and copy and paste it on your source code (noname00.cpp?). This is the same program that later edits the cpp file by interpreting other directives like #ifdef #endif macro blocks!
May 18 '15 #6
I did some quick googling of the documentation. I posted a link that is the closest thing I could find to the library path I was discussing above, but I actually don't feel comfortable with the UI shown in the screenshots I saw. Maybe, I have been pampered too much by Visual Studio, Code::Blocks, the Unix shells, and gcc.

http://www.softwareandfinance.com/Tu...y_Setting.html

The following link says you have to add the library to the project as well. Maybe you know what it refers to?

http://borland.public.install.bcpp.n...-w-turbo-c-3-0

If you are just starting to learn C++ and there are no special circumstances that forces you to use one compiler over another, I recommend you try gcc instead (Visual C++ is also good). I don't like the fact that I can't find ready made and in-depth documentation for Turbo C++. GCC has the advantage that you can start learning from either the shell, which is a great skill to have under your belt, or with an IDE (the IDE can range from something like emacs, vim, and the sort to something like Code::Blocks and VS). Well, the moderators can tell me if I am out of place for making this suggestion. Cheers!
May 18 '15 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: B_Love | last post by:
Hey! When trying to compile the code for a ordered vector class I get the following error: undefined reference to `WinMain@16' Anyone have any idea what I might be doing wrong? I've been...
4
by: Mark | last post by:
Hi, I'm trying to write some classes that kind of manage themselves. A linked list, that links different types of objects. Here's the code... object.h: --- class Object { int alt;
1
by: suryakantyadav | last post by:
Hi, I am beginer to c language. When i compile a programe, got an error msg:-- Linker error:Undefined symbal _ print in module test.c and my programe is like this.... main ( ) { print ( "...
0
by: Ehsan68 | last post by:
Hello my problem is "Linker Error: Undefined symbol _cga_driver_far in module maze.c " then Go to Options =>Linker =>Libraries This will display a box showing Container Class Turbo...
3
by: prakash.mirji | last post by:
Hello, I am getting below mention linker error when I tried to link my class test.C I use below command to compile test.C /usr/bin/g++ -g -fpic -fvisibility=default -D_POSIX_SOURCE...
2
by: kumarsatish | last post by:
The following C program in Turbo C is given the following error " Linker error:-Undefined Symbol _insert_point" #include<stdio.h> #include<conio.h> #define NULL 0 struct list_node
6
by: Ed Dana | last post by:
I'm trying to create a dynamic two dimensional array. My code looks like this: ====================================================================== #define DEF_FrameBuffer_H class FrameBuffer...
4
by: sanketiiit | last post by:
ERROR: Bloodshed Dev c++ undefined reference to cpu_features_init Perfect Solution to this error. If ( Installed MinGW ) then: 1. Uninstall MinGW 2. Delete manually MinGW Folder...
1
by: KBSethna | last post by:
Linker Error:Undefined Symbol ATM_c::run() in module Project.cpp Linker Error:Undefined Symbol ATM_c::ATM_c() in module Project.cpp ATM_c is a class having a function run() and a constructor....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.