0

I'm trying to bundle up my Mac application for distribution on various systems. I'm building on Apple Silicon but I want my app to be compatible with x86_64 systems and have some backwards compatibility (e.g. 10.11). I'm not using Xcode.

Using otool -L path/to/executable I find that my app requires libtiff.5.dylib which I cannot assume that users will have installed. So my idea was to compile the dylib for my target system (macOS 10.11, x86_64) and bundle it with the app.

$ otool -L path/to/executable
/usr/local/opt/libtiff/lib/libtiff.5.dylib (compatibility version 13.0.0, current version 13.0.0)

I've downloaded and compiled the libtiff dylib but when I run otool again I find that the version doesn't match the compatibility version above.

$ otool -L path/to/libtiff.5.dylib
@rpath/libtiffxx.5.dylib (compatibility version 5.0.0, current version 5.7.0)

When I bundle the dylib up with my executable and use install_name_tool to change the dylib path for my executable I get the expected error:

Library not loaded: @executable_path/../Frameworks/libtiff.5.dylib
  Referenced from: /path/to/bundle.app/Contents/MacOS/executable
  Reason: Incompatible library version: executable requires version 13.0.0 or later, but libtiff.5.dylib provides version 5.0.0

It seems I don't understand how dylib versioning works. How do I get the 13.0.0 version? Why would I even expect the 13.0.0 version if libtiff.5.dylib already has 5 in its name? Any why would I even expect version 5 if the offical version of libtiff is 4.3?

Additional info

I've directly downloaded the libtiff source code from the gitlab page. Maybe that's a mistake and I should have gone for one of the releases?

I've been using cmake to build the library with the following variables:

$ cmake ./ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.11 -DCMAKE_OSX_ARCHITECTURES=x86_64

Afterwards I run make and copy the newly created dylib files into my appbundle. I've tried compiling the dylib without the cmake variables but I get the same result.

Edit

I was previously using cmake to compile the dylib according to this page. However, when I just make a build directory and run ../configure from there, then the resulting dylib has the correct version. This introduces another problem, namely that I only get the dylib for arm64 architecture rather than x86_64.

chiasmos
  • 110
  • 7
  • 1
    Your file name says `libtiff`, but your install name says `libtiffxx`. Are you sure you've got the right library? Also, can't you just link against the actual dylib that you'll be shipping? Then you couldn't have any versioning issues. – Siguza Jun 27 '21 at 19:19
  • @Siguza It does say `libtiffxx`, I actually didn't realise. But I think your suggestion gave me the right idea. I shouldn't build extra libraries to ship with my bundle; rather, I should just ship the ones that I'm linking against. This seems to work on my test machine. I still have to test whether that works when I distribute my app to older OS versions. – chiasmos Jun 28 '21 at 08:53

0 Answers0