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

查看:261
本文介绍了如何安装和使用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 了解更多信息.

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

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

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

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