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

Home Posts Topics Members FAQ

Create and use a library

Hello,

1. How can I create a personnal library (with my own functions) ?
2. How can I use it ?
I know that in my source code I will have something like
#include "mylib.h"

But how to make a link between mylib.h and the library compiled ?

Thanks

Note that I read the FAQ first. I didn't find answer to my questions.
Nov 14 '05 #1
3 1532
Gattaca wrote:
Hello,

1. How can I create a personnal library (with my own functions) ?
2. How can I use it ?
I know that in my source code I will have something like
#include "mylib.h"

But how to make a link between mylib.h and the library compiled ?


a. Place all functions in a file with name "mylib.c".
b. Place all function declarations and other stuff (types,
macro's, #defined constants, ...) in the "mylib.h".
c. As you say, #include "mylib.n" in every source that
uses one or more of these library functions.
d. Compile "mylib.c", "source.c", ...
e. Link the object files into a program.

Step d. and e. can be done with one action/command for example:

cc source.c mylib.c -o myprog

This will invoke the linker as well. When you compile "source.c"
the compiler sees there are external functions (declared in "mylib.h")
and marks calls to them as unresolved. The linker makes a list
of all these unresolved externals and tries to find a match in
all object files it currently is processing. When there's a
match it fill in the right 'address' for each external.

HTH

Nov 14 '05 #2
Gattaca a écrit :
Sorry but I assume I was not clear enought.
When I said I wanted to create a personnal library It was rather
-> How can I create a personnal compiled library (not a C file)?
In order to keep my source code secret and to do "a public interface"
with a "mylib.h" header file.

Thanks

Hello,

1. How can I create a personnal library (with my own functions) ?
2. How can I use it ?
I know that in my source code I will have something like
#include "mylib.h"

But how to make a link between mylib.h and the library compiled ?

Thanks

Note that I read the FAQ first. I didn't find answer to my questions.

Nov 14 '05 #3
On Wed, 09 Jun 2004 16:32:24 +0200, Gattaca <ga*****@hotmail.com>
wrote:
Gattaca a écrit :
Sorry but I assume I was not clear enought.
When I said I wanted to create a personnal library It was rather
-> How can I create a personnal compiled library (not a C file)?
In order to keep my source code secret and to do "a public interface"
with a "mylib.h" header file.


[snip]

You would be better off asking this question in a vendor-specific
group, as Standard C has no concept of a "personnal library".

To point you in the right direction, you need to check your
implementation's documentation on its library manager (for MSVC this
is "lib.exe", for GNU C this is "ar"). You use the library manager to
collect all the object files generated from your TU's into one big
file. To use it, you need to let your linker know that it can check
out said library for otherwise unresolved references. Again, this is
implementation specific, and is entirely off-topic here.

--
Andrew

Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
1903
by: Mr. B | last post by:
I've an application in which I use to check out the date/time stamp of a data base... and if I find that it has been updated, my application runs and does a particular update. Currently I fire...
9
447
by: Amadrias | last post by:
Hi, In one of my current projects, I am willing to create a secure zone such as Acronis does in its application to store some confidential information only accessible to the current machine...
3
5898
by: Davide Bedin | last post by:
I have a "library" schema with the simple and complex types I commonly use in other schemas and then several other schemas, maybe created by other developers, that import/include the library...
2
9072
by: David Elliott | last post by:
I can create this: ?xml version="1.0" standalone="yes" ?> <ConfigOpt> <record> <Field_1>Text # 1</Field_1> <Field_2>Text # 2</Field_2> </record> </ConfigOpt>
1
3188
by: Stuart Dee | last post by:
Hi, How do i create a dcom or com+ component with visual basic dot net. Ive actually created it but the article tells me to register tlb and insert into gac How do I put it into MTS as a dcom...
4
1420
by: Scott Capistrant | last post by:
I am relatively new to the VB.net platform. How would I create a packaged exe that can run outside of my computer (i.e. load the needed dll's and such). Thanks.
10
8172
by: Steve | last post by:
I am trying to create a DLL in Visual Studio 2005-Visual Basic that contains custom functions. I believe I need to use COM interop to allow VBA code in Excel 2002 to access it. I've studied...
1
6169
by: yaarnick | last post by:
Create a linked list data structure library to hold strings. Then library should support the following linked list operations. Create() – Creates the linked list Insert() – Insert a string into the...
40
2282
by: Angus | last post by:
Hello I am writing a library which will write data to a user defined callback function. The function the user of my library will supply is: int (*callbackfunction)(const char*); In my...
0
7112
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
7146
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
7183
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
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4573
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
3084
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
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.