I have to maintain some legacy (MS) C++. In that codebase, I stumbled across:
#pragma comment(lib, "OtherLib700.lib")
Where 700 is some versioning. Besides, the lib is a DLL with the same name.
I first thought that the program would be dependent upon the DLL, but after removing it from the system, the program still works. There exists a newer version of the DLL, though, which is named OtherLib900.
It seems as though the program ‘included’ the code of the lib so that it’s no longer dependent upon the external DLL. (Or that the program ‘automatically’ uses the newer DLL.)
Which one is correct? Is there are way to further confirm that ‘assumption’?
If a program has this pragma it will look for the library
OtherLib700.lib. If that is an import library when the program is loaded windows will search forOtherLib700.dllin the path. It will not try to look forOtherLib900.dllduring execution so it must be finding yourdllin a different folder. This assumes thatOtherLib700.libis an import library and not a static library. If OtherLib700.lib is a static library then that is all it needs.The documentation for
#pragma comment( lib libname)states the following: