473,324 Members | 2,257 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,324 software developers and data experts.

What is the relation/difference between a header file, dll and library?

8
What is the relation/difference between a header file, dll and library?
Sep 29 '05 #1
11 20141
lini
12
A header file contains declaration of something (constants, classes, ...), usually ends with a .h or hpp extension.

A DLL (dynamically linked library) is a binary file (with .dll, .ocx, .a, ... extentions), containing functions, resources, ... and can be linked to your program at run-time. In order to use a DLL you need to include the corresponding header file, which declares things in the DLL, so that your program gets compiled. The DLL file is automatically loaded (by system) at run-time when your executable program invokes functions and asks for resources.

A library file (also called static library, with .lib extension usually) is a binary file which alsocontains functions and variables like DLL, but resolved at compile-time, meaning they need to be provided at link-time.

Dynamic and static libraries are often provided together with header file (but no source file, which contains the implementation) when the provider lets you use his/her functions/services but doesnt give you access to the implementation.

Is that what you ask?
Dec 15 '08 #2
donbock
2,426 Expert 2GB
Lini has summarized the generic meaning of "DLL". The same term is also used for the specific form of dynamic-link-library used by Windows and OS/2. Do you know whether you're referring to term generically or specifically in a Microsoft context?
Dec 15 '08 #3
MrPickle
100 100+
@lini
Is there a difference between .h & .hpp?
Dec 15 '08 #4
Banfa
9,065 Expert Mod 8TB
Not really. .h is a header file, .hpp is also a header file but typically only used in a C++ environment.

However when you get right down to it a header file can have any extension you want, it is only convention that uses h (for header).
Dec 15 '08 #5
Thanks. Good & clear answer pal
Jul 7 '09 #6
RedSon
5,000 Expert 4TB
What are the memory requirements between static and dynamic libs? For example how is the heap and stack represented on each? When a process uses a DLL does it make a copy of the whole DLL? Do singleton classes implmented in DLLs remain a singleton between processes?

What is a "DLL boundry"? Why is communicating across DLL boundaries difficult or complicated to achieve?

I recently switched to a different project and I'm afraid I don't know what I'm doing now... :(
Jul 9 '09 #7
JosAH
11,448 Expert 8TB
@RedSon
In every self respecting Linux/Unix distribnution the 'text segments' of .so files (the equivalent of dll files) are only loaded once, so if two or more people use the same .so file the text segment (the part where the code is) is loaded only once). When the last user stops his/her process the segment is unloaded.

Static libraries don't have that advantage, i.e. they are completely loaded by every process that was linked against the static library because the code is part of the entire process, i.e. executable file.

I assume the same scenario works for Microsoft's .dll files.

kind regards,

Jos
Jul 9 '09 #8
Banfa
9,065 Expert Mod 8TB
It is the same for Windows DLLs Jos.

One of the main differences between 16bit and 32bit windows is/was that under 16 bit windows memory used by a DLL was shared by all programs using the DLL. That is in 16bit Windows you could use a DLL to transfer data between programs easily.

In 32bit Windows the data used by DLLs is not shared between programs, each program instance of the DLL uses different data mapped into the programs virtual memory space. However the text segment (code) is only loaded once I believe.

Because the DLL and the application are different processes there are some class issues. For instance static data in a class used in a DLL and an application using the DLL results in the application and the DLL each having their own copy of the static data.
Jul 9 '09 #9
RedSon
5,000 Expert 4TB
@Banfa
Can you explain this in more detail?
Jul 9 '09 #10
JosAH
11,448 Expert 8TB
@RedSon
I don't understand it either; static class data is stored in the data segment and nowadays data segments are copied per process; it used to be different in the old days where data segments where shared between processes in MS Windows.

kind regards,

Jos
Jul 10 '09 #11
Banfa
9,065 Expert Mod 8TB
Sorry I thought I had better come back and explain myself. While I was sure I had heard of problems involving DLLs and static class data I can find no backing for this statement.

You do have to make sure you export everything from the DLL correctly or you would get linker errors (unresolved symbols) but that isn't terribly surprising not the blanket of doom I initially implied.

Our company coding standards suggest caution when using inline functions with classes in a DLL or shared library. If you plan on being able to update the DLL/so without changing the application (which is in theory possible) the inline functions cause a problem because they would be compiled straight into the application requiring an application rebuild rather than a simple DLL rebuild and redistribute.

However since there is a fair amount of evidence that our company C++ coding standard was written before the C++ standard was ratified I find myself not willing to trust it on this without a more recent corroboration that this behaviour is still true (although logically it does make sense).

A-hem,
nothing to see here
move along please
Jul 10 '09 #12

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

Similar topics

31
by: Steven T. Hatton | last post by:
If a header is not necessarily a source file, and the sequences delimited by < and > in header names aren't necessarily valid source file names, what exactly is a header? -- p->m == (*p).m == p.m...
4
by: s.subbarayan | last post by:
Dear all, How different is a header file from a library file in C?Under what circumstance u go for library and under what circumstance u go for header?Afaik,both have some declarations which can...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
1
by: C. Jayachandran | last post by:
I've inherited some code which has const std::string values defined in a header file, like const std::string str = "foo"; This causes a large amount of bloat, as all the compilation units...
11
by: Gary Wessle | last post by:
Hi is it right to have a line like #include <path/to/header.hfor a library on my system, in my header file and use some functions provided by this library in the implementation file (file.cpp)...
2
by: anarghya | last post by:
what does the header file contains?
3
by: silverWolf | last post by:
2. What is the relation between header file ( #include<iostream.h>) and input output function?
2
by: shariquehabib | last post by:
Hi All, Can any one let me know the correct diffrence between static library and dynamic library while using C language? ------------- Sharique
4
by: Sivani | last post by:
i need the header file for Sleep in Keil Operating system
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...
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...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.