aone
aone

Reputation: 67

Build bsdtar that uses custom liblzma.dylib library

Might be a very obvious thing to do, but I'm stuck on trying to build a bsdtar that uses a custom build version of liblzma.dylib, so I can share both the bsdtar binary and the liblzma.dylib library together.

Thanks to Tsyvarev comment, I'm building bsdtar with the custom the dylib, simply calling:

cmake -DCMAKE_PREFIX_PATH=customlib

No more need to use FIND_PACKAGE(liblzma HINTS customlib customlib/include) or similar. During the cmake process, the output looks like this:

-- Looking for lzma_auto_decoder in /libarchive-3.3.2/customlib/liblzma.dylib
-- Looking for lzma_auto_decoder in /libarchive-3.3.2/customlib/liblzma.dylib - found
-- Looking for lzma_easy_encoder in /libarchive-3.3.2/customlib/liblzma.dylib
-- Looking for lzma_easy_encoder in /libarchive-3.3.2/customlib/liblzma.dylib - found
-- Looking for lzma_lzma_preset in /libarchive-3.3.2/customlib/liblzma.dylib
-- Looking for lzma_lzma_preset in /libarchive-3.3.2/customlib/liblzma.dylib - found
-- Found LibLZMA: /libarchive-3.3.2/customlib/include (found version "5.2.3")

Anyway, the final build of bsdtar still looks for the system dylib, instead of the custom one:

aone$ otool -L libarchive-3.3.2/bin/bsdtar 
libarchive-3.3.2/bin/bsdtar:
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /usr/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.5)
    /usr/local/lib/liblzma.5.dylib (compatibility version 8.0.0, current version 8.3.0)
    ...

The folder customlib contains liblzma.5.dylib, it's alias liblzma.dylib and liblzma.a. The folder customlib/import contains lzma.h and and lzma folder with the rest of the headers.

Anyone has any clue how to do it properly? Thanks in advance.

Just asked it here: https://github.com/libarchive/libarchive/issues/1014

Upvotes: 0

Views: 174

Answers (1)

aone
aone

Reputation: 67

Finally did it post compilation with install_name_tool (man):

install_name_tool -change "/usr/local/lib/liblzma.5.dylib" "customlib/liblzma.dylib" bsdtar 

Upvotes: 0

Related Questions