Skip to content

Conversation

@vbieleny
Copy link
Contributor

Summary

Changes to recipe: xz_utils/5.8.1

Motivation

This is a fix for cross building from Windows to Android. At the moment, I encountered two issues. One issue was that msys2 was not used when building for Android with Autotools with xz_utils version 5.8.1. But even after fixing that, the Autotools failed while building. I fixed it by using CMake when building for Android on Windows since I don't have much experience with Autotools.

This PR fixes cross-compilation from Windows to Android. I encountered two issues during the process. The first was that MSYS2 wasn’t being used when building for Android with Autotools (xz_utils 5.8.1). After resolving that, the Autotools build still failed. Since I don’t have much experience with Autotools, I switched to using CMake for the Windows-to-Android build, which resolved the remaining issues.

Details

Initially, I had to update the following condition:

if self._settings_build.os == "Windows" and not self._use_msbuild and Version(self.version) < "5.8.1":

to:

if self._settings_build.os == "Windows" and not self._use_msbuild and not self._use_cmake:

Without this change, the build wouldn’t use msys2 at all and failed with the following error:

configure_error.txt

However, even after resolving that, the Autotools build still failed because it attempted to include windows.h while targeting Android. Relevant logs:

autotools_android_error.txt

Switching to CMake for Windows-to-Android builds resolves the issue, and the build completes successfully:

cmake_android_build.txt


  • Read the contributing guidelines
  • Checked that this PR is not a duplicate: list of PRs by recipe
  • If this is a bug fix, please link related issue or provide bug details
  • Tested locally with at least one configuration using a recent version of Conan

Add a 👍 reaction to pull requests you find important to help the team prioritize, thanks!

@uilianries uilianries self-requested a review November 28, 2025 08:40
@uilianries
Copy link
Member

@vbieleny Hello! Nice investigation over xz_utils to find Android support on Windows 😄

We had a similar case for libsocketcan where msys did not find the correct triplet, causing your mentioned error to find Windows header. As a solution, you can use the Conan configuration tools.gnu:host_triplet=aarch64-linux-android to enforce the correct triplet.

Using this approach, you can simplify your PR just to:

diff --git a/recipes/xz_utils/all/conanfile.py b/recipes/xz_utils/all/conanfile.py
index 2b77d6957..ae2dc5bb2 100644
--- a/recipes/xz_utils/all/conanfile.py
+++ b/recipes/xz_utils/all/conanfile.py
@@ -80,7 +80,7 @@ class XZUtilsConan(ConanFile):
         basic_layout(self, src_folder="src")

     def build_requirements(self):
-        if self._settings_build.os == "Windows" and not self._use_msbuild and Version(self.version) < "5.8.1":
+        if self._settings_build.os == "Windows" and not self._use_msbuild and (Version(self.version) < "5.8.1" or self.settings.os == "Android"):
             self.win_bash = True
             if not self.conf.get("tools.microsoft.bash:path", check_type=str):
                 self.tool_requires("msys2/cci.latest")

Using this approach I can build both versions 5.8.1 and 5.2.4 on Windows for Android using autotools. Please check my full build logs:

Regards!

@vbieleny
Copy link
Contributor Author

@uilianries Hi! Thanks for looking into this. I tried your solution and it worked for me as well. I’ll go ahead and make the necessary edits so it can be merged.

That said, it still feels like a workaround since it doesn’t work out of the box. Is this something that could be addressed more directly, for example, by somehow overriding the GNU host triplet in the android-ndk recipe, or even within Conan itself?

Have a nice weekend!

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

Successfully merging this pull request may close these issues.

2 participants