rustldmcrypt

Cargo build fails ld: library not found for -lmcrypt on Apple sillicon


I have installed mcrypt on my apple m1 chip using a brew and pecl

$ which mcrypt
/opt/homebrew/bin/mcrypt

$ pecl list
Installed packages, channel pecl.php.net:
=========================================
Package Version State
mcrypt  1.0.4   stable

However, when I build my personal Rust project locally, it fails to link libraries as follows. Is there some configuration that I am doing wrong or is there a parameter that I need to specify during the build?

= note: ld: library not found for -lmcrypt
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Cargo version

cargo -V
cargo 1.60.0 (d1fd9fe2c 2022-03-01)

ld -v

@(#)PROGRAM:ld  PROJECT:ld64-762
BUILD 06:28:58 Feb 18 2022
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
LTO support using: LLVM version 13.1.6, (clang-1316.0.21.2) (static support for 28, runtime is 28)
TAPI support using: Apple TAPI version 13.1.6 (tapi-1316.0.7.3)

sw_vers

ProductName:    macOS
ProductVersion: 12.3.1
BuildVersion:   21E258

Solution

  • I solved this issue. Just needed to export the $LIBRARY_PATH explicitly by typing:

    export LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/opt/mcrypt/lib/