Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.

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

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

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

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

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.

![]() |
![]() |
![]() |

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