How to add reference to other project's .lib stub

97 views Asked by At

Sorry if this has been asked before, but I can't seem to find an answer.

Let's say you have two projects within a solution. One is compiled to a dll, with an accompanying .lib for exports. You'd like to use and reference that module in your other project.

Can you somehow add a reference to the .lib stub within Solution Explorer? Or is that just for static libs? Thank you for your help.

1

There are 1 answers

0
jwezorek On

For implicit linking to a DLL, you can set up linking to the .lib stub exactly as you would if it was a full static library. For example, add "mylibstub.lib" to Configuration Properties/Linker/Input/Additional Dependencies and add the directory where it is built to Configuration Properties/Linker/General/Additional Library Directories as a path relative to the project directory.

Just doing the above should get you building. You are then going to need to get the DLL somewhere where it is going to be found when you run your executable from Visual Studio (assuming that the other project in the solution is an executable). One way to do this is to add the directory where the DLL is built to the path environment variable via Configuration Properties/Debug/Environment; see here. Another way would be copying it in a post-build step.