如何在 M1 MacBook 上安装 Cargo Generate

4

我正在尝试在我的M1 MacBook Air上安装cargo-generate。看起来连接器找到了x86_64版本的openssl

λ: cargo install cargo-generate                  
    Updating crates.io index
  Installing cargo-generate v0.13.1
   Compiling libc v0.2.126
...
// ********** snipped **********
...
   Compiling pest_derive v2.1.0
   Compiling thiserror-impl v1.0.31
   Compiling structopt-derive v0.4.18
   Compiling rhai_codegen v1.4.0
   Compiling failure v0.1.8
   Compiling pwd v1.3.1
   Compiling git-config v0.2.1
   Compiling thiserror v1.0.31
   Compiling rhai v1.7.0
   Compiling structopt v0.3.26
   Compiling kstring v2.0.0
   Compiling toml v0.5.9
   Compiling liquid-core v0.26.0
   Compiling liquid-lib v0.26.0
   Compiling liquid v0.26.0
   Compiling git2 v0.14.2
   Compiling cargo-generate v0.13.1
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-arch" "arm64" "/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/cargo-install93sXCR/release/deps/cargo_generate-3b067bb1f3f7f98a.cargo_generate.1172600b-cgu.0.rcgu.o" "-L" "/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/cargo-install93sXCR/release/deps" "-L" "/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/cargo-install93sXCR/release/build/libgit2-sys-33c3e15ed2a1170c/out/build" "-L" "/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/cargo-install93sXCR/release/build/libssh2-sys-d45cf615a1338664/out/build" "-L" "/usr/local/opt/openssl@3/lib" "-L" "/Users/carsonrajcan/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/rustcgt1KX4/liblibgit2_sys-ea90ee25efac1064.rlib" "/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/rustcgt1KX4/liblibssh2_sys-31bfafe03b9ec440.rlib" "/Users/carsonrajcan/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-4d2eba102ddf9fce.rlib" "-liconv" "-framework" "Security" "-framework" "CoreFoundation" "-lssl" "-lcrypto" "-lz" "-liconv" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" "-L" "/Users/carsonrajcan/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/cargo-install93sXCR/release/deps/cargo_generate-3b067bb1f3f7f98a" "-Wl,-dead_strip" "-nodefaultlibs"
  = note: ld: warning: ignoring file /usr/local/opt/openssl@3/lib/libssl.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
          ld: warning: ignoring file /usr/local/opt/openssl@3/lib/libcrypto.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
          Undefined symbols for architecture arm64:
            "_EVP_ripemd160", referenced from:
                _mac_method_hmac_ripemd160_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
            "_EVP_md5", referenced from:
                _mac_method_hmac_md5_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
            "_HMAC_Final", referenced from:
                _mac_method_hmac_sha2_256_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_sha2_512_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_sha1_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_md5_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_ripemd160_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
            "_HMAC_CTX_free", referenced from:
                _mac_method_hmac_sha2_256_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_sha2_512_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_sha1_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_md5_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_ripemd160_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
            "_EVP_cast5_cbc", referenced from:
                _libssh2_crypt_method_cast128_cbc in liblibssh2_sys-31bfafe03b9ec440.rlib(crypt.o)
...
// ********** snipped **********
...
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: failed to compile `cargo-generate v0.13.1`, intermediate artifacts can be found at `/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/cargo-install93sXCR`

Caused by:
  could not compile `cargo-generate` due to previous error

我不确定我的系统上是否安装了正确版本的openssl。

我该如何确保已安装并对链接器可见正确的(macOS-arm64openssl版本?

或者如果这不是问题,我该如何让编译器与我已经拥有的版本兼容?


1
你可能可以强制使用一些预构建的东西?我记得在其他的板条箱中看到过类似的东西。 - Netwave
你是正确的。我找到了 vendored-openssl 标志并且它起作用了。 - C-RAD
2个回答

3
你需要启用 vendored-openssl 标志:
cargo install cargo-generate --features "vendored-openssl"

0

我仍然不确定如何使用系统的openssl,但正如@Netwave建议的那样,我能够继续使用vendored-openssl标志:

cargo install cargo-generate --features vendored-openssl

我在文档中找到了。


1
哦,我和你同时写的 :D - Netwave
虽然很高兴能帮上忙。 - Netwave

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接