动态加载静态库? [英] dynamically loading static library?

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

问题描述

Linux 中的静态库 *.a 能否在运行时动态加载?
我读过这里

Can a static libary *.a in Linux be dynamically loaded at runtime?
I've read here that

...静态库和共享库都可以用作动态加载的库.

...both static and shared libraries can be used as dynamically loaded libraries.

如何动态加载静态库?

推荐答案

静态库或多或少只是目标文件的集合.如果要在程序中使用静态库,则必须将可执行文件与其链接.然后可执行文件将包含静态库(或您使用的部分).

A static library is more or less just a collection of object files. If you want to use a static library in a program, you have to link the executable with it. The executable will then contain the static library (or the parts that you used).

如果您想在运行时使用 dlopen 加载静态库,您必须首先创建一个包含它的动态库 libfoo.so.

If you want to load a static library at runtime using dlopen, you will have to first create a dynamic library libfoo.so containing it.

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

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