具有动态依赖关系的静态库 [英] Static library with dynamic dependencies

查看:50
本文介绍了具有动态依赖关系的静态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了很多类似的问题,但我并没有真正得到答案.

I have come across quite a few similar questions, however I didn't really get my answer.

所以,我有一个依赖于 Static.lib 的 App.exe,而后者又依赖于动态库 Dynamic.dll.在 Static.lib 中,我链接到 Dynamic.lib 导入库.我知道现在 App.exe 必须在其目录中包含 Dynamic.dll 才能成功运行,但是当我尝试链接代码时,我收到一个错误,即 App 项目找不到 Dynamic.lib 导入库.

So, I have an App.exe that depends on Static.lib, which in turn depends on a dynamic library Dynamic.dll. In Static.lib I link to Dynamic.lib import library. I do understand that now the App.exe has to have Dynamic.dll in it's directory in order to run successfully, however when I try to link the code I get an error that the App project can't find Dynamic.lib import library.

我的问题是,为什么App项目已经在Static.lib中链接了,为什么还要链接到Dynamic.lib导入库?

My question is, why does the App project have to link to Dynamic.lib import library when it is already linked in Static.lib?

推荐答案

我的问题是,为什么App项目要链接到Dynamic.lib已在 Static.lib 中链接时导入库?

My question is, why does the App project have to link to Dynamic.lib import library when it is already linked in Static.lib?

首先,您需要生成静态库,因此您使用共享库的头文件进行编译并链接到共享库.

At first, you need to generate your static library, so you compile with the shared library's header files and you link with the shared library.

然后用静态库的头文件编译生成一个.exe;然后需要链接共享库,因为在静态库中找到的一些方法是在共享库中实现的.

Then to generate an .exe you compile with the static library's header files; Then you need to link with the shared library because some of the methods found in the static library are implemented in the shared library.

这篇关于具有动态依赖关系的静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆