How do you use libtool to create .a files (static libraries) on Mac OS?
Asked Answered
V

1

5

When it comes to using the terminal to build libraries manually and such I unfortunately do not have much experience and I'm stuck a bit here.

I've downloaded a library for objective-c which came with makefiles and such.

I can see that the folder also contains an executable file called "libtool", I did some searching and I suppose this is the program I have to use to build the neccessary .a files? Unfortunately I couldn't really find any useful article for this that seemed to work.

The folder for the library contains some .sh files, .pc files and also some .la files, but I'm a bit unsure of which ones I have to use as input to the libtool program to compile them into a .a file.

So my question is what files do you have to input into libtool to compile them into the necessary .a file? And what commands do you use exactly to accomplish this?

Thank you all for your time :)

Victorvictoria answered 7/9, 2012 at 9:21 Comment(0)
L
9

First a little introduction to static libraries:

Static libraries in Unix environments (like Mac OSX, and Linux too) are actually just an archive of object files created by the ar command line program.

That is what the .a extension stands for: Archive.

To create a static library with some object files you can use the command like this:

ar crv libmy_library.a objectfile1.o objectfile2.o

As for your actual question, libtool should be called automatically from the makefile, creating the library, which is the file ending in .la. However, this is not the real library, the real library is in a hidden directory. You can find it by doing e.g.

find . -name '*.a'

But like I said, the makefile should already take care of everything, including installing the correct library in the correct place when you do e.g. make install.

For information about libtool, see this site.

Lunnete answered 7/9, 2012 at 9:29 Comment(1)
Cool, thanks for the additional information too! Very useful :) And yes I found out that the makefile did actually build the libraries, just not in the same folder ;) They were build to a locale folder of the file system. Thank you for the help :)Victorvictoria

© 2022 - 2024 — McMap. All rights reserved.