Search code examples
macosbuildlibarchive

Building LibArchive as a static library on MacOS


I am trying to build LibArchive according to the manual here: https://github.com/libarchive/libarchive/wiki/BuildInstructions . I am building it on MacOS, using the configure/make way. I was able to build it just fine, producing .libs/libarchive.a which I need.

However the library cannot extract LZMA compression. Going back to ./configure script, I have found that it is outputting checking for lzma.h... no, so it seems that it is not linked with lzma library, so the capability is then not there. I have tried to install brew install xz (which contains lzma), I can see lzma.h in /opt/homebrew/include, I can create a small C program with #include <lzma.h> and successfully compile it with gcc.

But the ./configure script is still giving me checking for lzma.h... no .

The question is - how to build libarchive.a with lzma capability on MacOS? And more broadly - how to build libarchive.a with as much capabilities as possible? I need the library to handle all formats it can.

Edit: This is the complete output of ./configure: https://drive.google.com/file/d/1kUtQQBTznmoSUy9WMhp38E4nDTPSO6rh/view?usp=share_link


Solution

  • Got it working at last. I had to specify library path through CFLAGS ... I had previously no experience with commandline building, so this was like exploration of the new world for me.

    sudo ./configure CFLAGS="-I/opt/homebrew/include -L/opt/homebrew/lib"
    
    sudo make CFLAGS="-I/opt/homebrew/include -L/opt/homebrew/lib"