question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cross compiling from Linux to Android

See original GitHub issue

I am trying to build an Android project from Linux. I am getting the following message from conan package tools.

Page       :  1
Builds list:
[('settings', {'os': 'Android', 'os.api_level': 24, 'arch': 'x86', 'build_type': 'Debug', 'compiler': 'clang', 'compiler.version': '5.0', 'compiler.libcxx': 'libc++'}), ('options', {}), ('env_vars', {}), ('build_requires', {})]

############## CONAN PACKAGE TOOLS ######################

DEBUG: - Skipped build, compiler mismatch: {'arch': 'x86', 'build_type': 'Debug', 'compiler': 'clang', 'compiler.libcxx': 'libc++', 'compiler.version': '5.0', 'os': 'Android', 'os.api_level': '24'}

#########################################################

If I run

  • conan create orhun/testing -s os=Android -s os.api_level=24 ... directly it works.
  • If I remove relevant code from _run_test_package in test_package_runner.py, it works.

Is the check in _run_test_package in error or am I missing something?

Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
orhun-sketchupcommented, Aug 30, 2017

It’s an old check that I think can be deleted because of the latest package tools improvements, but we should check it carefully before removing it.

That’s why I was thinking I was missing something. I generally work on windows and I didn’t hit this check previously because it skips the check on windows.

I think the check at least should verify we are cross building or not (i.e. check whether default_profile["os"] == settings.get("os") ). In my case default_profile["os"] is Linux but settings.get("os") is Android.

At that point I think conan-package-tools could assume user have set their cross build environment correctly. Basically _detected_compiler_override is too early if I am setting CC and CXX through conan package dependencies.

Note: I just noticed what _detected_compiler_override does. If I had noticed it earlier, I would have just set these variables in my ‘build.py’ for my cross compiles to something else. They don’t even have to be correct, since conan will set them for me later, during the actual build. See below.

But how is conan locating your toolchain to cross build to Android?

I have a ndk-toolchain conan package similar to conan-android-toolchain that sets env_info.CC and env_info.CXX, and my package requires it in its build_requirements.

in ndk-toolchain:

    def package_info(self):
        self.env_info.CC  = os.path.join(self.package_folder, 'toolchain', 'bin', 'clang')
        self.env_info.CXX = os.path.join(self.package_folder, 'toolchain', 'bin', 'clang++')

in package that uses ndk-toolchain for cross compile:

    def build_requirements(self):
        if self.settings.os == 'Android':
            self.build_requires(f'ndk-toolchain/r15c@{self.user}/{self.channel}')
0reactions
lasotecommented, Aug 31, 2017

I’ve released a new version removing that check. I think it has become not necessary some time ago but we didn’t remove it. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cross compiling a C program for android
I am trying to copy an executable from my Linux machine (Ubuntu) to an Android app as an asset.
Read more >
Cross Compiling C/C++ for Android - Nick Desaulniers
This will create a nice standalone bundle in ~/arm . It will contain our cross compiler, linker, headers, libs, and sysroot (crt.o and...
Read more >
Cross compile from GNU Linux to Android
Webcamoid is a full featured and multiplatform webcam suite. - Cross compile from GNU Linux to Android · webcamoid/webcamoid Wiki.
Read more >
Use the NDK with other build systems
Some makefile projects allow cross compilation by overriding the same variables that you would with an autoconf project. As an example, the ...
Read more >
Let's Build Chuck Norris! - Part 6: Cross-compilation for Android
Those files do not exist on Android, because even if Android is based on Linux, it's still a different operating system. See the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found