Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 :)

like image 367
CodingBeagle Avatar asked Sep 07 '12 09:09

CodingBeagle


1 Answers

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.

like image 58
Some programmer dude Avatar answered Oct 05 '22 12:10

Some programmer dude