简体   繁体   English

如何添加对其他项目的.lib 存根的引用

[英]How to add reference to other project's .lib stub

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.一个编译为 dll,附带一个用于导出的.lib。 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?你能以某种方式在解决方案资源管理器中添加对.lib 存根的引用吗? Or is that just for static libs?还是仅适用于 static 库? Thank you for your help.谢谢您的帮助。

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.对于到 DLL 的隐式链接,您可以设置与.lib 存根的链接,就像它是一个完整的 static 库一样。 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.例如,将“mylibstub.lib”添加到Configuration Properties/Linker/Input/Additional Dependencies ,并将构建它的目录添加到Configuration Properties/Linker/General/Additional Library Directories作为相对于项目目录的路径。

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).然后,您需要在从 Visual Studio 运行可执行文件时可以找到 DLL 的地方(假设解决方案中的另一个项目是可执行文件)。 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 ;一种方法是通过Configuration Properties/Debug/Environment将构建 DLL 的目录添加到路径环境变量; see here .看这里 Another way would be copying it in a post-build step.另一种方法是在构建后步骤中复制它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM