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

Unable to cross-compile Android #63

Open
Liloupar opened this issue Oct 15, 2024 · 3 comments
Open

Unable to cross-compile Android #63

Liloupar opened this issue Oct 15, 2024 · 3 comments

Comments

@Liloupar
Copy link

Liloupar commented Oct 15, 2024

The Android NDK is already configured, but executing cargo build --target aarch64-linux-android --release returns the following error.

warning: unused manifest key: target.aarch64-linux-android.ar
warning: unused manifest key: target.aarch64-linux-android.linker
   Compiling unrar_sys v0.5.6
The following warnings were emitted during compilation:

warning: [email protected]: In file included from vendor/unrar/extinfo.cpp:14:
warning: [email protected]: vendor/unrar/ulinks.cpp:39:3: error: use of undeclared identifier 'lutimes'; did you mean 'utimes'?
warning: [email protected]:   lutimes(LinkNameA.c_str(),tv);
warning: [email protected]:   ^~~~~~~
warning: [email protected]:   utimes
warning: [email protected]: /Users/a/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/../sysroot/usr/include/sys/time.h:47:5: note: 'utimes' declared here
warning: [email protected]: int utimes(const char* __path, const struct timeval __times[2]);
warning: [email protected]:     ^
warning: [email protected]: 1 error generated.

error: failed to run custom build command for `unrar_sys v0.5.6`

Caused by:
  process didn't exit successfully: `/Users/a/code/world_hello/target/release/build/unrar_sys-e9f65f8b46bf7e99/build-script-build` (exit status: 1)
  --- stdout
  cargo:rustc-link-lib=pthread
  OUT_DIR = Some(/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out)
  TARGET = Some(aarch64-linux-android)
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXX_aarch64-linux-android
  CXX_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXX_aarch64_linux_android
  CXX_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXX
  TARGET_CXX = None
  cargo:rerun-if-env-changed=CXX
  CXX = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(false)
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-linux-android
  CXXFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_linux_android
  CXXFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  OUT_DIR = Some(/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-linux-android
  CXXFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_linux_android
  CXXFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  OUT_DIR = Some(/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-linux-android
  CXXFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_linux_android
  CXXFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  OUT_DIR = Some(/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-linux-android
  CXXFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_linux_android
  CXXFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  OUT_DIR = Some(/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-linux-android
  CXXFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_linux_android
  CXXFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  OUT_DIR = Some(/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-linux-android
  CXXFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_linux_android
  CXXFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  OUT_DIR = Some(/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-linux-android
  CXXFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_linux_android
  CXXFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  OUT_DIR = Some(/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-linux-android
  CXXFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_linux_android
  CXXFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  OUT_DIR = Some(/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-linux-android
  CXXFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_linux_android
  CXXFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  OUT_DIR = Some(/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-linux-android
  CXXFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_linux_android
  CXXFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  OUT_DIR = Some(/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-linux-android
  CXXFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_linux_android
  CXXFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  OUT_DIR = Some(/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-linux-android
  CXXFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_linux_android
  CXXFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  OUT_DIR = Some(/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-linux-android
  CXXFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_linux_android
  CXXFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  OUT_DIR = Some(/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64-linux-android
  CXXFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CXXFLAGS_aarch64_linux_android
  CXXFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  cargo:warning=In file included from vendor/unrar/extinfo.cpp:14:
  cargo:warning=vendor/unrar/ulinks.cpp:39:3: error: use of undeclared identifier 'lutimes'; did you mean 'utimes'?
  cargo:warning=  lutimes(LinkNameA.c_str(),tv);
  cargo:warning=  ^~~~~~~
  cargo:warning=  utimes
  cargo:warning=/Users/a/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/../sysroot/usr/include/sys/time.h:47:5: note: 'utimes' declared here
  cargo:warning=int utimes(const char* __path, const struct timeval __times[2]);
  cargo:warning=    ^
  cargo:warning=1 error generated.

  --- stderr


  error occurred: Command "aarch64-linux-android21-clang" "-O2" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-std=c++14" "-stdlib=libc++" "-fPIC" "-Wno-switch" "-Wno-parentheses" "-Wno-macro-redefined" "-Wno-dangling-else" "-Wno-logical-op-parentheses" "-Wno-unused-parameter" "-Wno-unused-variable" "-Wno-unused-function" "-Wno-missing-braces" "-Wno-unknown-pragmas" "-Wno-deprecated-declarations" "-D_FILE_OFFSET_BITS=64" "-D_LARGEFILE_SOURCE" "-DRAR_SMP" "-DRARDLL" "-o" "/Users/a/code/world_hello/target/aarch64-linux-android/release/build/unrar_sys-b778bd4a5a8a1827/out/01e88f00c6928482-extinfo.o" "-c" "vendor/unrar/extinfo.cpp" with args aarch64-linux-android21-clang did not execute successfully (status code exit status: 1).
@ttys3
Copy link
Contributor

ttys3 commented Dec 2, 2024

error: use of undeclared identifier 'lutimes'

first, you need __ANDROID_API__ >= 26

then, you need macro _GNU_SOURCE define

ref

https://stackoverflow.com/a/68222332

https://www.gnu.org/software/gnulib/manual/html_node/lutimes.html

@Liloupar
Copy link
Author

Liloupar commented Dec 10, 2024

error: use of undeclared identifier 'lutimes'

first, you need __ANDROID_API__ >= 26

then, you need macro _GNU_SOURCE define

ref

https://stackoverflow.com/a/68222332

https://www.gnu.org/software/gnulib/manual/html_node/lutimes.html

@ttys3
Should I add the following to the build.rs file in the unrara.rs project?

    .define("__USE_GNU", None)
    .define("__ANDROID_API__", Some("26"))

Is there a way to configure this without modifying the source code of the unrara.rs project?

Thank you for your response.

@ttys3
Copy link
Contributor

ttys3 commented Dec 10, 2024

you can try that.

but I think these macros should be defined by your toolchain, to claims it support some kind of feature.

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