LoginSignup
3
1

More than 3 years have passed since last update.

rust-opencvのcargo buildでlibclang.dylib(macOS)がみつからなかったときのメモ

Last updated at Posted at 2021-02-04

rustでディープラーニングしてみようと思い、

$ cargo new rust-opencv-study
Cargo.toml
[package]
name = "rust-opencv-study"
version = "0.1.0"
authors = ["user.name <user.email>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
opencv = "0.49.1"

の、

$ cargo build

で、こんなとき

   Compiling opencv v0.49.1
error: failed to run custom build command for `opencv v0.49.1`

Caused by:
  process didn't exit successfully: `/Users/takahiro/Documents/source/rust-opencv/target/debug/build/opencv-eee0ce442a19ac9b/build-script-build` (signal: 6, SIGABRT: process abort signal)
  --- stderr
  dyld: Library not loaded: @rpath/libclang.dylib
    Referenced from: /Users/takahiro/Documents/source/rust-opencv/target/debug/build/opencv-eee0ce442a19ac9b/build-script-build
    Reason: image not found

には、

$ ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib /usr/local/Cellar/rust/1.49.0_1/lib/rustlib/x86_64-apple-darwin/lib/libclang.dylib

で、

$ cargo build
   Compiling opencv v0.49.1
   Compiling rust-opencv v0.1.0 (/Users/takahiro/Documents/source/rust-opencv)
    Finished dev [unoptimized + debuginfo] target(s) in 2m 24s

ダン、でした。

リファレンス

@github rust-lang/rust - rust-lld fails with "dyld: Library not loaded: @rpath/libLLVM.dylib" on 1.30.0-nightly (02cb8f2a4 2018-08-29) #53813

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1