0

After rebooting my dev machine, my Rust project stopped running on macOS. The error message is:

dyld: Symbol not found: __cg_jpeg_resync_to_restart
  Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
  Expected in: /usr/local/lib/libJPEG.dylib
 in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO

I have absolutely no idea what changed and caused this. The problem seems to be with my rig, not with the code, since it runs fine on a Docker container, and the older commits refuse to run on my computer. Another thing is that my project shouldn't be using any image-processing libraries. (And I don't know how to list transitive dynamic dependencies on macOS to check whether it really does.)

otool -L /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO reveals that ImageIO links to /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib (compatibility version 1.0.0, current version 1.0.0). That file exists indeed. /usr/local/lib/libjpeg.dylib (My FS is case-insensitive) exists too, but it's a symlink to a homebrewed file ../Cellar/jpeg/8d/lib/libjpeg.dylib, so clearly the system library shouldn't use that. However, I have not set LD_LIBRARY_PATH or any other env var that – as far as I know – should coerce macOS to use /usr/local/lib as a dylib search path.

So my questions are:

1) Is there a tool on macOS to check, which libraries in my project link (possibly transitively) to the ImageIO.framework?

2) How are dylib search paths configured on macOS? Is there a tool to check which paths are searched and in which preference order? The problem itself might be due to some Homebrew problem, but I'd like to have the tools to diagnose and understand it.

GolDDranks
  • 3,272
  • 4
  • 22
  • 30

1 Answers1

0

I still don't know a good answer for 1).

For 2) the answer can be found from the Apple docs. This page lists all the env vars that affect dylib loading and their default values: https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/dyld.1.html

For the mystery, why the wrong path was attempted to be loaded: although my environment didn't have any funny variables set, my build tool (cargo run) set DYLD_LIBRARY_PATH before running the binaries. This is because of the behaviour (not sure if bug) explained here: https://github.com/sgrif/pq-sys/commit/3ad9f7b77a6c4f50d5d7277bce05c836a62a4398

GolDDranks
  • 3,272
  • 4
  • 22
  • 30