如何安装和使用 libtool 共享库(.lo 文件)? [英] How to install and use libtool shared library (.lo files)?

查看:35
本文介绍了如何安装和使用 libtool 共享库(.lo 文件)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以在我运行 libtool 并从我的库源中取出 libfoo.lofoo.o 文件后,我如何转换 libfoo.lo 文件转换成一个普通的 Linux 共享库,比如 libfoo.so.1.0.0 以便我可以在我的目标系统上安装并链接到它?

So after I ran libtool and got out a libfoo.lo and foo.o file from my library source, how do I convert the libfoo.lo file into a normal Linux shared library, like libfoo.so.1.0.0 so I can install and link to it on my target system?

推荐答案

从问题中提到的输出来看,您似乎使用 --mode=compile 模式运行了 libtool.您将需要使用 --mode=link 再次运行 libtool 以生成 .a 和 .so 库.

From the outputs mentioned in the question, it looks like you ran libtool with --mode=compile mode. You will need to run libtool again with --mode=link to produce .a and .so libraries.

libtool 只是生成库所需的 gcc、ln ar 和 ranlib 的简单包装器.它所做的只是运行 gcc,添加必要的选项以确保正确创建静态和共享库.

libtool is just a simple wrapper for gcc, ln ar and ranlib which is needed to produce libraries. All it does is run gcc adding the necessary options to ensure that your static and shared libraries are created correctly.

在编译 libtool 时插入 -fPIC 标记以确保必要生成共享库所需的位置无关代码..o 文件是可以归档到静态 .a 文件中的普通目标文件..lo 文件是具有位置无关代码的目标文件,现在可以链接到 .so 文件中.

When compiling libtool inserts the -fPIC tag to ensure the necessary generation of position independent code needed for shared libraries. The .o files are normal object files that can be archived into a static .a file. The .lo files are object files with position independent code which can now be linked into a .so file.

链接 libtool 时将运行 ar 创建静态库或 ln 将目标文件链接到 .so 共享库.

When linking libtool will run ar to create a static library or ln to link the objects files into a .so shared library.

libtool 也可以在需要时使用 --mode=install 安装库.

libtool also can install the library when desired using the --mode=install.

参见 http://www.gnu.org/software/libtool/manual/libtool.html 了解更多信息.

See http://www.gnu.org/software/libtool/manual/libtool.html for more info.

请记住,在构建可执行文件时,总是有两个阶段,编译和链接.

Please remember that when building an executable there are always two stages, compiling and linking.

这篇关于如何安装和使用 libtool 共享库(.lo 文件)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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