Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to build x86_64-apple-darwin binary on ARM silicon #221

Open
jiabochao opened this issue Nov 9, 2024 · 2 comments
Open

Failed to build x86_64-apple-darwin binary on ARM silicon #221

jiabochao opened this issue Nov 9, 2024 · 2 comments

Comments

@jiabochao
Copy link

hi, when I compile the rust-ffmpeg x86 program on Apple M2 Pro macOS 15.1, I get an error

Cargo.toml

ffmpeg-next = {git = "https://github.com/zmwangx/rust-ffmpeg.git", branch = "master"}

error message:

error: failed to run custom build command for `ffmpeg-sys-next v7.1.0`

Caused by:
  process didn't exit successfully: `/Users/bochao/Work/projects/SearchIn/src-tauri/target/release/build/ffmpeg-sys-next-201ad7040f4dd9cc/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBAVUTIL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_apple_darwin
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_apple_darwin
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_apple_darwin
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at /Users/bochao/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ffmpeg-sys-next-7.1.0/build.rs:795:14:
  called `Result::unwrap()` on an `Err` value: pkg-config has not been configured to support cross-compilation.

  Install a sysroot for the target platform and configure it via
  PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
  cross-compiling wrapper for pkg-config and set it via
  PKG_CONFIG environment variable.
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
failed to build x86_64-apple-darwin binary: failed to build app
    Error failed to build x86_64-apple-darwin binary: failed to build app
 ELIFECYCLE  Command failed with exit code 1.
@caobug
Copy link

caobug commented Dec 12, 2024

Did you solve it?

@jiabochao
Copy link
Author

jiabochao commented Dec 13, 2024

Did you solve it?

@caobug Try this

  1. Install Rosetta2 via terminal using:
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
  1. Once Rosetta 2 is installed, install Homebrew for the x86_64 chip.
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  1. Then install the x86_64 version of the ffmpeg libraries.
arch -x86_64 /usr/local/bin/brew install ffmpeg
arch -x86_64 /usr/local/bin/brew install pkg-config
  1. Set PKG_CONFIG env (pkg-config bin path)
# use your own pkg-config path
export PKG_CONFIG=/usr/local/Cellar/pkg-config/0.29.2_3/bin/pkg-config
  1. build rust-ffmpeg again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants