Can't compile open-ssl to android

I got an error:

  --- stderr
  /bin/sh: C:Users...AppDataLocalAndroidSdkndk21.3.6528147toolchainsllvmprebuiltwindows-x86_64binaarch64-linux-android29-clang.cmd: command not found
  make[1]: *** [Makefile:659: crypto/aes/aes_cbc.o] Error 127
  make: *** [Makefile:172: build_libs] Ошибка 2
  thread 'main' panicked at '


  Error building OpenSSL:
      Command: "make" "build_libs"
      Exit status: exit code: 2


      ', C:\Users\...\.cargo\registry\src\github.com-1ecc6299db9ec823\openssl-src-111.11.0+1.1.1h\src\lib.rs:410:13
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: Command 'cargo build --target aarch64-linux-android' had a non-zero exit code.

My toolchain is windows-gnu.
Also path is a quite weird /bin/sh: C:Users...AppDataLocalAndroidSdkndk21.3.6528147toolchainsllvmprebuiltwindows-x86_64binaarch64-linux-android29-clang.cmd: command not found

OpenSSL dependency isn't built using just the Rust compiler. It needs a special C compiler able to cross-compile to Android, or a pre-compiled Android library available on the system. Windows-gnu toolchain is not sufficient for this. You have to have Android SDK installed and configured.

The error message complains about lack of clang for your particular target. Check out that directory and see if it exists, and what commands for what targets you can use.

How can I specify path to clang?

It looks like somewhere the path to the Android NDK directory is not escaped correctly. It probably needs backslashes escaped, like this:

C:\\Users\\...\\AppData\\Local\\Android\\Sdk\\ndk

Did you provide this path in a config file or environment variable somewhere? If so, try escaping it as above. If not, this may be a bug in the build scripts for openssl-sys.

Nah, I've specified path in .cargo/config, but there's still the same error:

 /bin/sh: C:Users...AppDataLocalAndroidSdkndk21.3.6528147toolchainsllvmprebuiltwindows-x86_64binaarch64-linux-android29-clang.cmd: command not found

It's kinda weird - there's /bin/sh but I'm on Windows

Just to clarify, did you escape the backslashes in the .cargo/config?

Sure

Hmm. It's hella weird that build script tries to use /bin/sh. I'm on Windows, what the heck?

The build script is running make, which runs sh.

You could also try using forward slashes instead of backslashes. I suspect the OpenSSL makefiles aren’t properly handling paths with escaped characters in them.

Seems it's the problem with NDK autodetection - https://github.com/alexcrichton/cc-rs/commit/d20f57b2629ed1f5a020b604ba692994663b6b95

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.