Computing.Net > Forums > Programming > static vs dynamic lib

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

static vs dynamic lib

Reply to Message Icon

Name: Sukhwinder Singh
Date: November 13, 2001 at 12:43:15 Pacific
Comment:

Hello,
1. I want to know if a program on windows is linked to a static library then why it demands a dll file at runtime. I know when a program is linked against a static library then library code is included in program executable.

For example to compile openldap-2.0.11 with MS Visual c++ I needed hs_regex.lib and I included it in lib directory and compiled openldap. But when I run openldap it asks for hs_regex.dll.

Are files in lib directory with .lib extension static libraries? If yes then why at runtime a dll file is needed?

2. What is the difference between file with .obj file and .lib file?

3. My last question is when I compiled openldap it needed hs_regex.lib but I downloaded gnu_regex.lib and renamed it to hs_regex.lib because It was specified in all projects. Then when I run opoenldap it then asks for gnu_regex.dll not hs_regex.dll. How openldap is able to determine it needs gnu_regex.dll and not hs_regex.dll.



Sponsored Link
Ads by Google

Response Number 1
Name: Mik
Date: November 14, 2001 at 08:19:24 Pacific
Reply:

You've got a pretty weird case there. Normally if you link a static library you don't need the dynamic one. I don't know how these libraries work or how you are linking the right library. But you might want to check all your options and compiler switches to make sure you aren't somehow including both the static and the dynamic version.

Usually the .lib ones are static and the .dll ones are dynamic.
A .obj file is just like a library because it contains a set of procedures. But usually .obj files are created when compiling and then linked together into one program by the compiler.

Mik


0

Response Number 2
Name: Sukhwinder Singh
Date: November 14, 2001 at 12:56:19 Pacific
Reply:

Hello,
Thank you very much for your answer. So, either dynamic or static library is needed. And if a program is linked against a static library then dll is not needed.

When I downloaded openldap there was already a visual c++ 6.0 project file and I didn't change project settings much, as I don't know much about windows programming. I don't know if openldap people had made any mistake in project settings.

So a question arises, Is it possible to dynamically link a program to a static lib? So that it looks for functions in static library when linking and at runtime in a dll file.

Sukhwinder


0

Response Number 3
Name: Sukhwinder Singh
Date: November 14, 2001 at 15:47:14 Pacific
Reply:

Hello,
I also had some information from this page on experts-exchange you also can check this page http://www.experts-exchange.com/jsp/qShow.jsp?ta=winprog&qid=20230915
Sukhwinder


0

Response Number 4
Name: Guy Allard
Date: November 14, 2001 at 20:32:50 Pacific
Reply:

Comment: On most OS's it is possible to write code that goes into a static library, and write it in such a way that *it* requires a DLL to run. So your resulting executable would still require the DLL.

Although with Windows and MSVC++ .... you may indeed have a IDE/project setup problem.

Regards, Guy



0

Response Number 5
Name: Sukhwinder Singh
Date: November 15, 2001 at 12:10:37 Pacific
Reply:

Thank you Mr guy and Mik for your help. I have cleared my doubts.....


0

Related Posts

See More



Response Number 6
Name: Sukhwinder
Date: November 16, 2001 at 13:06:04 Pacific
Reply:

Sorry...rather you have cleared my doubts..


0

Response Number 7
Name: Krishnaraddi.R.Manka
Date: January 15, 2002 at 01:41:01 Pacific
Reply:

Hi,
There can be two type of .lib files..

1. Library containing the object code of the source. this file can be liked statically..that is object source goes with the application.

2. Library file generated along with the Dll file. This file is contatining the export symbols of the Dll and with this libary Symbols can be resolved at compile time but there wont any object code binding.Dll is required in this case when a n exported symbol is used in the application..this is called as implicit linking ( part of dynamic linking ) here all the symboles are resolved at compile time and actual resolution of symbole takes place at runtime for which you need the corresponding dll.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: static vs dynamic lib

C newbie2 - strtok www.computing.net/answers/programming/c-newbie2-strtok/4581.html

qbasic question www.computing.net/answers/programming/qbasic-question/9548.html

loading dlls www.computing.net/answers/programming/loading-dlls/19646.html