Is it possible to identify the library that correspond to certain header files? Is it possible to identify the library that correspond to certain header files? windows windows

Is it possible to identify the library that correspond to certain header files?


I think the answer of this question may help you a lot: Tools for inspecting .lib files?.

You may write a simple script, which loop through all lib files in the directory, and call dumpbin to dump symbols of all the libs out to a file started with the lib name, so later you can search symbol you need in the generated file to get the correct lib.


"Can I programmatically determine which library must be used."

Not within the same program/codebase. The "programmatic" (say template tricks etc.) ability remains till the compilation stage. Once the linking starts (as of today), the control is gone.

"Is there anything I can do, knowing that the correct library exists in the same directory?"

Again No. I don't intend to demotivate you, but what you are asking is not going to be helpful anyways. Suppose, somehow you manage to find a way to know if the library exists in the same directory. What purpose will it serve? Because practically a library can reside in any path. One has to simply set the path variables in the MSVC or -L option in gcc. So the question of having the library in the same directory is moot.

Probably you may want to ask, how to know if the library exists in your system & where.
Well, this is ofcourse not possible programmatically in the same code base. Because you have to run that codebase to find if the library exists somewhere in your system. To run that codebase, you have to link it. Chicken-Egg problem.
Either you check manually or write your own separate script/code to do this task.


Maybe its better to use the dllGetProcAddress function in C++or if you write lib itself you can add code in header like this:'#'pragma comment( lib, "libname.lib" )hope its help