Build a command line tool without dynamically linking to specific file location (macOS)

32 views Asked by At

I'm working on a small utility that uses the libtiff tools tiff2pdf and tiffcp. I would like to be able to distribute it with the binaries for those two tools so that it could be run from wherever it is downloaded to.

I've built libtiff following the instructions here but after building, the tools rely on libtiff.5.dylib which is in a location specific to my machine based on the step ./configure --prefix=/path_here.../. I also tried ./configure --enable-static --prefix=/path_here.../ but according to otool -l tiff2pdf it's still dynamically linked.

Is there a generic method that will produce a binary that isn't linked to a hard coded location on the system? Linking to a relative path would be fine if that's possible.

1

There are 1 answers

0
arsenius On BEST ANSWER

The answer was in ./configure --help. Using --enable-static doesn't force the executables to be statically linked because --enable-shared is still used. --disable-shared did the trick.