473,473 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to create a library?

57 New Member
Hi I have few functions whose definitions I have put up in mycode.c and whose declarations I have put in mycode.h. I want to create a library for this file and for some others also. I want this works similar like math.h or string.h. How can I do so?

I am using Dev C and Windows XP


Please help me

Thank You
Dec 12 '09 #1
4 6277
Markus
6,050 Recognized Expert Expert
The header files aren't *really* part of the library.

Compile your library to a .dll file and then using your linker, link the library to your project.

You'll have to read about how to link it because it's specific to your compiler/linker.
Dec 12 '09 #2
puneetsardana88
57 New Member
Compile your library to a .dll file

How i do that using Dev c++. Can you explain the procedure or provide a link for the same?Regarding linking I can put these library where others libraries are kept.....


Thank you for the reply
Dec 13 '09 #3
Banfa
9,065 Recognized Expert Moderator Expert
A library is a collection of code with no entry point. The code can be shared, as in a DLL (or shared object on Linux) in which case the code is never in the program that links to the library but is loaded by the OS in some fashion. Alternatively the code can be static, part of a static library, this is more like a repository of object files and when I program is linked against a static library those object files are copied out of the library and into the program so the code is in the program.

In all cases a library consists of a binary file containing the code, a header file declaring the public symbols (functions, classes and variables) in the library and sometimes. In the case of a DLL a much smaller binary file, a static library, also exists containing the code that knows how to load and call the main DLL file. I am not sure if Linux shared objects require something like this too.

When creating a library you compile you code in the normal fashion, although for a DLL you sometimes need extra directives in the code to indicate which functions will be externally visible to calling programs.

Where it differs is in the link stage, for a program you call the linker that creates a program, resolving all symbols. For a static library you call a librarian program (or archiver in gcc) that just gathers the object files together into the library without resolving all symbols.

A DLL is actually an executable image so it too is created with the linker but special switches need to be passed to the linker to tell it to create a DLL.

However if you are using an IDE (such as Dev-C which, by the way, is somewhat outdated now) then generally it is just a matter of creating a project that creates the correct output, the IDE takes care of calling the correct tools with the correct switches. So for instance to create a library you would create a new project that creates a static library or you would create a new project that creates a DLL.

Having created the library you should not put it where the other libraries are kept, that directory contains standard libraries and may well be overwritten when a new compiler version comes out. You should leave the standard library directory alone and under the control of the program that created it (not you).

Again most IDEs allow you to load multiple projects and you can make one project refer to another. If you do this and the project being refered to is a library then many IDEs will automatically link the library into the referring project. This has the advantage that if you build the debug version of you program you get the debug version of the library and if you build the release version of you program you get the release version of your library.

If your IDE does not do this then it will certainly have a section under the linker configuration of your program where you can specify additional libraries.
Dec 13 '09 #4
puneetsardana88
57 New Member
Thanks Banfa that was really nice explanation. Thanks a ton.
Dec 13 '09 #5

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

Similar topics

2
by: pieter.breed | last post by:
Hi All, The company I work for has traditionally used COM/ActiveX for the solutions that it provides. We are in the process of moving to .NET and a few applications have been written in VB.NET...
43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
4
by: Ardhendu Nandan | last post by:
Hi, Like turbo c(tlib.exe),is there any utility in gcc to add new library? regards Ardhendu
7
by: TJ | last post by:
In C# how do you achieve pass-by-reference property declarations in the Type Library? I am writing a COM Class Library that must mimick an existing library for which the only information is the...
3
by: Manny Silva | last post by:
Hi, I would like to create a static library that uses and in effect adds to another static library. I could simply add functionality to the existing library, but functionally it doesn't really...
1
by: JIM.H. | last post by:
Hello, I have more than one application and I want to use my functions in many application, how can I do this? Is it possible to create library and use it in another .net application. Thanks,...
0
by: WStoreyII | last post by:
I am trying to use vb.net 2003 to make a class library that i can use in wsh(vbscript files) so i made a test dll and when i ran the script it said that the class was not setup for automation. ...
3
by: Miguel Ferreira via .NET 247 | last post by:
Hi ! I have developed a class Library with several classes and methods. Its working fine with a windows forms test application, but now i need to create a webservice that will expose those...
13
by: Daniel Kay | last post by:
Hello folks! Is it right, that it's not a very good idea to use STL datatypes (std::string, std::list, ...) for library interfaces? Because someone might try to use that library with a different...
5
by: Laszlo Nagy | last post by:
Hi, I want py2exe not to create library.zip. My reason is that the installed program will be a self updating program, and it must be able to download changes (newer python source files) from the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.