How to install and use libtool shared library (.lo files)?
Asked Answered
N

1

4

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?

Nevanevada answered 31/12, 2009 at 15:45 Comment(0)
G
8

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 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.

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.

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

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

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.

Generable answered 31/12, 2009 at 16:8 Comment(1)
libtool --mode=finish also has to be used to "complete the installation of libtool libraries" for some systems. Just compile/link/install is not sufficient.Kendrick

© 2022 - 2024 — McMap. All rights reserved.