对库的可执行依赖
共享可执行文件时,我真的需要担心用于制作该可执行文件的库吗?似乎在生成 exe 时应该考虑这一点,而不是在必须运行它时考虑。只是好奇。我很确定我不必担心,但想问这个问题来确定一下。安全总比后悔好。
When sharing an executable do i really need to worry about libraries used to make that executable? seems like that should be taken into consideration when generating the exe not when you have to run it. Just curious. I am pretty sure I don't have to worry but wanted to ask this question to make sure. better to be safe than sorry.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是静态链接和动态链接的区别。正如您所猜测的,通过静态链接,库代码的相关部分将直接包含(复制)到您的二进制文件中。对于动态链接,存在运行时依赖性;您的二进制文件将使用依赖于操作系统的技术来访问(依赖于操作系统的)共享库中的代码,例如 Win32 上的 DLL 或 Linux 上的 SO。
如果您不确定您的程序是使用静态链接还是动态链接进行编译,请参阅编译器文档。此外,还有一些工具可以检查二进制文件头中的“导入表”或等效项,并确定它们依赖哪些共享库(如果有)。为此,我在 Linux 和 Windows 下使用 GNU
objdump
和-x
选项。This is the difference between static and dynamic linking. With static linking, as you've surmised, the relevant portions of library code are directly included (copied) into your binaries. With dynamic linking, a run-time dependency exists; your binary will use OS-dependent techniques to access code in (OS-dependent) shared libraries, such as DLLs on Win32 or SOs on Linux.
If you're not sure whether your program is being compiled with static or dynamic linking, consult your compiler documentation. Additionally, there are tools which can examine the headers of binaries for "import tables" or equivalent and determine what shared libraries, if any, they depend upon. I use GNU
objdump
with the-x
option for this purpose, under both Linux and Windows.