Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link multiple DLLs from one import library (lib)

In the CRT description on MSDN, there is the following sentence:

For binary compatibility, more than one DLL file may be specified by a single import library.

What does this mean?

Assuming I manually link msvcp140.dll and msvcp140_1.dll, does adding a single msvcprt.lib to dependencies mean that both DLLs will be linked?

For this, I looked into some options related to lib.exe (Microsoft Library Manager) and realized that it is impossible to create a single import library (lib) through multiple .def files.

However, I confirmed that it is possible to link multiple DLLs through a single lib by merging the Import Library (lib) generated when building two DLLs using the lib.exe command.

I'm not sure if this is the best way to do it.

How does msvcprt.lib work so that both msvcp140.dll and msvcp140_1.dll can be linked?

Additionally, I found that the C++Builder solution provided by Embarcadero has a utility called implib.exe and a method to create a single lib using multiple custom defs, but this is not a Microsoft standard (however, it is compatible with MVSC).

I'm a newbie to this area, so I'd appreciate some concrete examples, rather than just a simple answer like "look at msdn".

like image 395
arcane22 Avatar asked Nov 17 '25 06:11

arcane22


1 Answers

Assuming I manually link msvcp140.dll and msvcp140_1.dll

That's not how it works. You link a .lib. When that's an import lib, you get a runtime dependency on one or more DLLs. The OS will then load those dependent DLLs (typically when the EXE is loaded i.e. the process is created).

It does not matter to you exactly what Microsoft did to create that import library. They're only telling you that there can be multiple DLLs involved because you might need to redistribute those DLLs with your executable.

The "binary compatibility" part is because there are existing EXE files in the wild which make (bad) assumptions about the content of msvcp140.dll.

an Embarcadero utility called implib

This is not a utility which you'll need as a newbie. In fact, I haven't needed it in 30 years.

like image 81
MSalters Avatar answered Nov 18 '25 20:11

MSalters



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!