可执行文件生成后可以链接到动态库吗? [英] Can an executable be linked to a dynamic library after its built?

查看:399
本文介绍了可执行文件生成后可以链接到动态库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一个二进制'foo'.我现在希望将可执行文件链接到动态库"bar".如何将foo链接到bar?(使用ld或任何其他方式).我不想在OSX上使用DYLIB_INSERT_PATH或在Linux上使用等效的LD_PREOAD.

I have built a binary 'foo'. I now want the executable to be a linked to a dynamic library 'bar'. How can I link foo to bar?(using ld or any other way). I don't want to use DYLIB_INSERT_PATHon OSX or its equivalent LD_PREOAD on Linux.

我想在OSX上执行此操作,但这是一个通用的问题.

I want to do this on OSX, but this question is a generic one.

推荐答案

您打算做什么?

链接过程解析符号:它满足需求.

The link process resolves symbols: it provide satisfactions to needs.

如果可执行文件不需要动态库提供的任何符号,则链接程序将完全丢弃它.

If the executable doesn't need any symbols offers by the dynamic library, the linker will entirely discard it.

您可以将动态库替换为另一个动态库,但是当动态库不存在时,您将无法解决该需求.

You may replace a dynamic library by another one but you can't resolve a need when it doesn't exists.

这篇关于可执行文件生成后可以链接到动态库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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