conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.16k stars 973 forks source link

Android tutorial can't be compiled on Windows #2511

Closed alexxxgu closed 1 year ago

alexxxgu commented 6 years ago

I was trying to build boost for android under windows according to http://blog.conan.io/2018/02/13/Android-Studio-project-Conan-Boost.html

1) using cmake shipped with default sdk and mingw32-make: The C compiler "C:/Android/arm_21_toolchain/bin/arm-linux-androideabi-clang" is not able to compile a simple test program. ..... Error running link command: %1 is not a valid Win32 application

2) using CMake from the official site: -- The C compiler identification is GNU 4.9.0 -- The CXX compiler identification is GNU 4.9.0 .... Incorrect 'clang', is not the one detected by CMake: 'GNU' Call Stack (most recent call first): .... ERROR: bzip2/1.0.6@conan/stable: Error in build() method, line 46 cmake.configure(build_dir=".", source_dir="..") ConanException: Error 1 while executing cd . && cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_SYSTEM_NAME="Android" -DCONAN_CMAKE_FIND_ROOT_PATH="C:/Android/arm_21_toolchain/sysroot" -DCMAKE_SYSROOT="C:/Android/arm_21_toolchain/sysroot" -DCMAKE_ANDROID_ARCH_ABI="armeabi-v7a" -DCONAN_EXPORTED="1" -DCONAN_COMPILER="clang" -DCONAN_COMPILER_VERSION="5.0" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="C:\Users\user.conan\data\bzip2\1.0.6\conan\stable\package\9b5efed8fbf1cba00152d97f255eab56c82b3ef9" -DFPIC="ON" -Wno-dev ..

Conan version 1.0.4 Android Studio 3.0.1 Android NDK 16.1.4479499 no Visual Studio installed

is it possible to disable -G "MinGW Makefiles" ? Or another way to build for Android on Windows. On linux works fine.

lasote commented 6 years ago

Hi, I really don't know how MinGW is involved in this process. Did you follow the previous blog post to build boost? Could you show me the profile being used to build it? Following the step 2) error in your traces, it looks like CMake is detecting GCC instead of the clang from the toolchain.

alexxxgu commented 6 years ago

Сonan calls cmake -G "MinGW Makefiles", and yes it was building of the boost's dependency . Just following http://blog.conan.io/2018/01/30/Cross-building-Boost-Android.html:

C:\ndk\build\tools>python make_standalone_toolchain.py --arch=arm --api=21 --stl=libc++ --install-dir=C:/ndk/arm_21_toolchain

C:\ndk\build\tools>type C:\Users\user.conan\profiles\android_21_armeabi-v7a_clang standalone_toolchain=C:/ndk/arm_21_toolchain target_host=arm-linux-androideabi cc_compiler=clang cxx_compiler=clang++

[settings] compiler=clang compiler.version=5.0 compiler.libcxx=libc++ os=Android os.api_level=21 arch=armv7 build_type=Release

[env] CONAN_CMAKE_FIND_ROOT_PATH=$standalone_toolchain/sysroot PATH=[$standalone_toolchain/bin] CHOST=$target_host AR=$target_host-ar AS=$target_host-as RANLIB=$target_host-ranlib CC=$target_host-$cc_compiler CXX=$target_host-$cxx_compiler LD=$target_host-ld STRIP=$target_host-strip CFLAGS= -fPIC -I$standalone_toolchain/include/c++/4.9.x CXXFLAGS= -fPIC -I$standalone_toolchain/include/c++/4.9.x LDFLAGS=

cmake from system:

C:\Users\user\Documents>SET PATH=%PATH%;"c:\Program Files\CMake\bin"

C:\Users\user\Documents>rd /s /q conan-boost

C:\Users\user\Documents>rd /s /q C:\Users\user.conan\data

C:\Users\user\Documents>git clone -b release/1.66.0 https://github.com/lasote/conan-boost Cloning into 'conan-boost'... remote: Counting objects: 1030, done. remote: Compressing objects: 100% (4/4), done. remote: Total 1030 (delta 1), reused 3 (delta 1), pack-reused 1025 Receiving objects: 100% (1030/1030), 253.72 KiB | 363.00 KiB/s, done. Resolving deltas: 100% (639/639), done.

C:\Users\user\Documents>cd conan-boost

C:\Users\user\Documents\conan-boost>conan create . conan/stable --build missing --profile=android_21_armeabi-v7a_clang boost/1.66.0@conan/stable: Exporting package recipe Linter warnings WARN: Linter. Line 1: Unable to import 'conans' WARN: Linter. Line 2: Unable to import 'conans' WARN: Linter. Line 3: Unable to import 'os' WARN: Linter. Line 42: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 43: Instance of 'dict' has no 'remove' member WARN: Linter. Line 47: Instance of 'dict' has no 'without_iostreams' member WARN: Linter. Line 47: Instance of 'dict' has no 'header_only' member WARN: Linter. Line 58: Instance of 'dict' has no 'header_only' member WARN: Linter. Line 73: Instance of 'dict' has no 'header_only' member WARN: Linter. Line 90: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 104: Instance of 'tuple' has no 'arch' member WARN: Linter. Line 106: Instance of 'tuple' has no 'arch' member WARN: Linter. Line 109: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 112: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 112: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 113: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 115: Instance of 'tuple' has no 'os' member WARN: Linter. Line 115: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 118: Instance of 'dict' has no 'shared' member WARN: Linter. Line 119: Instance of 'tuple' has no 'build_type' member WARN: Linter. Line 128: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 129: Instance of 'dict' has no 'fPIC' member WARN: Linter. Line 133: Instance of 'tuple' has no 'os' member WARN: Linter. Line 135: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 137: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 139: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 140: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 156: Instance of 'tuple' has no 'get_safe' member WARN: Linter. Line 160: Instance of 'tuple' has no 'arch' member WARN: Linter. Line 162: Instance of 'tuple' has no 'get_safe' member WARN: Linter. Line 183: Instance of 'tuple' has no 'os' member WARN: Linter. Line 186: Instance of 'tuple' has no 'os' member WARN: Linter. Line 202: Instance of 'tuple' has no 'os' member WARN: Linter. Line 202: Instance of 'tuple' has no 'os' member WARN: Linter. Line 231: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 232: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 233: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 234: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 247: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 250: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 252: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 259: Instance of 'tuple' has no 'os' member WARN: Linter. Line 259: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 260: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 263: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 264: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 271: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 272: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 272: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 291: Instance of 'dict' has no 'shared' member WARN: Linter. Line 311: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 354: Instance of 'dict' has no 'without_test' member WARN: Linter. Line 360: Instance of 'dict' has no 'header_only' member WARN: Linter. Line 360: Instance of 'dict' has no 'shared' member WARN: Linter. Line 365: Instance of 'dict' has no 'header_only' member WARN: Linter. Line 366: Instance of 'dict' has no 'without_python' member WARN: Linter. Line 367: Instance of 'dict' has no 'shared' member WARN: Linter. Line 370: Instance of 'tuple' has no 'compiler' member boost/1.66.0@conan/stable: A new conanfile.py version was exported boost/1.66.0@conan/stable: Folder: C:\Users\user.conan\data\boost\1.66.0\conan\stable\export bzip2/1.0.6@conan/stable: Retrieving from predefined remote 'conan-center' bzip2/1.0.6@conan/stable: Trying with 'conan-center'... Downloading conanmanifest.txt [==================================================] 107B/107B Downloading conanfile.py [==================================================] 2.5KB/2.5KB Downloading conan_export.tgz [==================================================] 451B/451B zlib/1.2.11@conan/stable: Retrieving from predefined remote 'conan-center' zlib/1.2.11@conan/stable: Trying with 'conan-center'... Downloading conanmanifest.txt [==================================================] 121B/121B Downloading conanfile.py [==================================================] 5.7KB/5.7KB boost/1.66.0@conan/stable (test package): Installing C:\Users\user\Documents\conan-boost\test_package\conanfile.py Requirements boost/1.66.0@conan/stable from conan-center bzip2/1.0.6@conan/stable from conan-center zlib/1.2.11@conan/stable from conan-center Packages boost/1.66.0@conan/stable:fdbf42b5c4db68948c32d5d25ee01619aa3dd1a4 bzip2/1.0.6@conan/stable:9b5efed8fbf1cba00152d97f255eab56c82b3ef9 zlib/1.2.11@conan/stable:39a53587004d75943e385925ca011baeab537de0

Cross-build from 'Windows:x86_64' to 'Android:armv7' bzip2/1.0.6@conan/stable: Building your package in C:\Users\user.conan\data\bzip2\1.0.6\conan\stable\build\9b5efed8fbf1cba00152d97f255eab56c82b3ef9 bzip2/1.0.6@conan/stable: Configuring sources in C:\Users\user.conan\data\bzip2\1.0.6\conan\stable\source [==================================================] 763.7KB/763.7KB bzip2/1.0.6@conan/stable: Copying sources to build folder bzip2/1.0.6@conan/stable: Generator cmake created conanbuildinfo.cmake bzip2/1.0.6@conan/stable: Calling build() CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred! bzip2/1.0.6@conan/stable: bzip2/1.0.6@conan/stable: ERROR: Package '9b5efed8fbf1cba00152d97f255eab56c82b3ef9' build failed bzip2/1.0.6@conan/stable: WARN: Build folder C:\Users\user.conan\data\bzip2\1.0.6\conan\stable\build\9b5efed8fbf1cba00152d97f255eab56c82b3ef9 ERROR: bzip2/1.0.6@conan/stable: Error in build() method, line 46 cmake.configure(build_dir=".", source_dir="..") ConanException: Error 1 while executing cd . && cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_SYSTEM_NAME="Android" -DCONAN_CMAKE_FIND_ROOT_PATH="C:/ndk/arm_21_toolchain/sysroot" -DCMAKE_SYSROOT="C:/ndk/arm_21_toolchain/sysroot" -DCMAKE_ANDROID_ARCH_ABI="armeabi-v7a" -DCONAN_EXPORTED="1" -DCONAN_COMPILER="clang" -DCONAN_COMPILER_VERSION="5.0" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="C:\Users\user.conan\data\bzip2\1.0.6\conan\stable\package\9b5efed8fbf1cba00152d97f255eab56c82b3ef9" -DFPIC="ON" -Wno-dev ..

alexxxgu commented 6 years ago

Adding mingw32-make.exe inside the toolchain leads to gnu compiller: C:\Users\user>SET PATH=%PATH%;"c:\Program Files\CMake\bin"

C:\Users\user>rd /s /q conan-boost

C:\Users\user>rd /s /q C:\Users\user.conan\data

C:\Users\user>git clone -b release/1.66.0 https://github.com/lasote/conan-boost Cloning into 'conan-boost'... remote: Counting objects: 1030, done. remote: Compressing objects: 100% (4/4), done. remote: Total 1030 (delta 1), reused 3 (delta 1), pack-reused 1025 Receiving objects: 100% (1030/1030), 253.72 KiB | 395.00 KiB/s, done. Resolving deltas: 100% (639/639), done.

C:\Users\user>cd conan-boost

C:\Users\user\conan-boost>conan create . conan/stable --build missing --profile=android_21_armeabi-v7a_clang boost/1.66.0@conan/stable: Exporting package recipe Linter warnings WARN: Linter. Line 1: Unable to import 'conans' WARN: Linter. Line 2: Unable to import 'conans' WARN: Linter. Line 3: Unable to import 'os' WARN: Linter. Line 42: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 43: Instance of 'dict' has no 'remove' member WARN: Linter. Line 47: Instance of 'dict' has no 'without_iostreams' member WARN: Linter. Line 47: Instance of 'dict' has no 'header_only' member WARN: Linter. Line 58: Instance of 'dict' has no 'header_only' member WARN: Linter. Line 73: Instance of 'dict' has no 'header_only' member WARN: Linter. Line 90: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 104: Instance of 'tuple' has no 'arch' member WARN: Linter. Line 106: Instance of 'tuple' has no 'arch' member WARN: Linter. Line 109: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 112: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 112: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 113: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 115: Instance of 'tuple' has no 'os' member WARN: Linter. Line 115: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 118: Instance of 'dict' has no 'shared' member WARN: Linter. Line 119: Instance of 'tuple' has no 'build_type' member WARN: Linter. Line 128: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 129: Instance of 'dict' has no 'fPIC' member WARN: Linter. Line 133: Instance of 'tuple' has no 'os' member WARN: Linter. Line 135: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 137: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 139: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 140: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 156: Instance of 'tuple' has no 'get_safe' member WARN: Linter. Line 160: Instance of 'tuple' has no 'arch' member WARN: Linter. Line 162: Instance of 'tuple' has no 'get_safe' member WARN: Linter. Line 183: Instance of 'tuple' has no 'os' member WARN: Linter. Line 186: Instance of 'tuple' has no 'os' member WARN: Linter. Line 202: Instance of 'tuple' has no 'os' member WARN: Linter. Line 202: Instance of 'tuple' has no 'os' member WARN: Linter. Line 231: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 232: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 233: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 234: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 247: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 250: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 252: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 259: Instance of 'tuple' has no 'os' member WARN: Linter. Line 259: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 260: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 263: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 264: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 271: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 272: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 272: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 291: Instance of 'dict' has no 'shared' member WARN: Linter. Line 311: Instance of 'tuple' has no 'compiler' member WARN: Linter. Line 354: Instance of 'dict' has no 'without_test' member WARN: Linter. Line 360: Instance of 'dict' has no 'header_only' member WARN: Linter. Line 360: Instance of 'dict' has no 'shared' member WARN: Linter. Line 365: Instance of 'dict' has no 'header_only' member WARN: Linter. Line 366: Instance of 'dict' has no 'without_python' member WARN: Linter. Line 367: Instance of 'dict' has no 'shared' member WARN: Linter. Line 370: Instance of 'tuple' has no 'compiler' member boost/1.66.0@conan/stable: A new conanfile.py version was exported boost/1.66.0@conan/stable: Folder: C:\Users\user.conan\data\boost\1.66.0\conan\stable\export bzip2/1.0.6@conan/stable: Retrieving from predefined remote 'conan-center' bzip2/1.0.6@conan/stable: Trying with 'conan-center'... Downloading conanmanifest.txt [==================================================] 107B/107B Downloading conanfile.py [==================================================] 2.5KB/2.5KB Downloading conan_export.tgz [==================================================] 451B/451B zlib/1.2.11@conan/stable: Retrieving from predefined remote 'conan-center' zlib/1.2.11@conan/stable: Trying with 'conan-center'... Downloading conanmanifest.txt [==================================================] 121B/121B Downloading conanfile.py [==================================================] 5.7KB/5.7KB boost/1.66.0@conan/stable (test package): Installing C:\Users\user\conan-boost\test_package\conanfile.py Requirements boost/1.66.0@conan/stable from conan-center bzip2/1.0.6@conan/stable from conan-center zlib/1.2.11@conan/stable from conan-center Packages boost/1.66.0@conan/stable:fdbf42b5c4db68948c32d5d25ee01619aa3dd1a4 bzip2/1.0.6@conan/stable:9b5efed8fbf1cba00152d97f255eab56c82b3ef9 zlib/1.2.11@conan/stable:39a53587004d75943e385925ca011baeab537de0

Cross-build from 'Windows:x86_64' to 'Android:armv7' bzip2/1.0.6@conan/stable: Building your package in C:\Users\user.conan\data\bzip2\1.0.6\conan\stable\build\9b5efed8fbf1cba00152d97f255eab56c82b3ef9 bzip2/1.0.6@conan/stable: Configuring sources in C:\Users\user.conan\data\bzip2\1.0.6\conan\stable\source [==================================================] 763.7KB/763.7KB bzip2/1.0.6@conan/stable: Copying sources to build folder bzip2/1.0.6@conan/stable: Generator cmake created conanbuildinfo.cmake bzip2/1.0.6@conan/stable: Calling build() -- Android: Targeting API '21' with architecture 'arm', ABI 'armeabi-v7a', and processor 'armv7-a' -- The C compiler identification is GNU 4.9.0 -- The CXX compiler identification is GNU 4.9.0 -- Check for working C compiler: C:/ndk/arm_21_toolchain/bin/arm-linux-androideabi-gcc.exe -- Check for working C compiler: C:/ndk/arm_21_toolchain/bin/arm-linux-androideabi-gcc.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: C:/ndk/arm_21_toolchain/bin/arm-linux-androideabi-g++.exe -- Check for working CXX compiler: C:/ndk/arm_21_toolchain/bin/arm-linux-androideabi-g++.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Conan: called by CMake conan helper CMake Error at C:/Users/user/.conan/data/bzip2/1.0.6/conan/stable/build/9b5efed8fbf1cba00152d97f255eab56c82b3ef9/conanbuildinfo.cmake:374 (message): Incorrect 'clang', is not the one detected by CMake: 'GNU' Call Stack (most recent call first): C:/Users/user/.conan/data/bzip2/1.0.6/conan/stable/build/9b5efed8fbf1cba00152d97f255eab56c82b3ef9/conanbuildinfo.cmake:58 (conan_check_compiler) CMakeLists.txt:4 (CONAN_BASIC_SETUP)

-- Configuring incomplete, errors occurred! See also "C:/Users/user/.conan/data/bzip2/1.0.6/conan/stable/build/9b5efed8fbf1cba00152d97f255eab56c82b3ef9/bzip2-1.0.6/_build/CMakeFiles/CMakeOutput.log". bzip2/1.0.6@conan/stable: bzip2/1.0.6@conan/stable: ERROR: Package '9b5efed8fbf1cba00152d97f255eab56c82b3ef9' build failed bzip2/1.0.6@conan/stable: WARN: Build folder C:\Users\user.conan\data\bzip2\1.0.6\conan\stable\build\9b5efed8fbf1cba00152d97f255eab56c82b3ef9 ERROR: bzip2/1.0.6@conan/stable: Error in build() method, line 46 cmake.configure(build_dir=".", source_dir="..") ConanException: Error 1 while executing cd . && cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_SYSTEM_NAME="Android" -DCONAN_CMAKE_FIND_ROOT_PATH="C:/ndk/arm_21_toolchain/sysroot" -DCMAKE_SYSROOT="C:/ndk/arm_21_toolchain/sysroot" -DCMAKE_ANDROID_ARCH_ABI="armeabi-v7a" -DCONAN_EXPORTED="1" -DCONAN_COMPILER="clang" -DCONAN_COMPILER_VERSION="5.0" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="C:\Users\user.conan\data\bzip2\1.0.6\conan\stable\package\9b5efed8fbf1cba00152d97f255eab56c82b3ef9" -DFPIC="ON" -Wno-dev ..

lasote commented 6 years ago

Could you confirm that the Conan running is 1.0.4? Did you installed with pip or are you using some of the installers? I'm seeing very weird things in your trace, like the linting problems that shouldn't appear.

alexxxgu commented 6 years ago

Yes, I've installed it from https://bintray.com/conan/installers/download_file?file_path=conan-win-64_1_0_4.exe

lasote commented 6 years ago

Hi @alexxxgu I've been able to reproduce both the linter traces with the windows installer and the error with CMake, it is finding g++ instead of clang, I'm investigating. Thanks for reporting.

lasote commented 6 years ago

It look like setting:

CONAN_CMAKE_SYSTEM_NAME=False
CONAN_CMAKE_GENERATOR=Unix Makefiles

in the profile, I've been able to do some progress, but unfortunately still doesn't work, there are two different problems:

a) CMake is not able to recognize the compiler, and Conan is failing checking if the specified compiler is the detected by CMake. (I'll open an issue to see if it can be solved) b) Even patching that in the code the zlib library build is failing to build in Windows for Android.

So, I'm sorry but it looks like it is not so easy to make it work in Windows. The blog post maybe should be updated to explain this.

alexxxgu commented 6 years ago

Thanks, I'll build it under Linux for now ( WSL) I know it's wrong place to ask, but is it possible to build OpenSSL along with boost using clang for Android? both clang and gcc fail.

lasote commented 6 years ago

Looks like it is an open discussion in the OpenSSL community: https://github.com/openssl/openssl/pull/2229 Please open an issue here https://github.com/conan-community/community/issues and maybe we can check if there is any progress in the OpenSSL community to make it happen.

Bjoe commented 6 years ago

Hi. I create a pull request Android build with clang on conan-openssl. Unfortunately its not ready yet. Test package step fails and I'm not yet an conan package profi. Maybe somebody have an idea.

gindemit commented 6 years ago

Hi @lasote ! I have the same problem with zlib/1.2.11@conan/stable Cross-build from 'Windows:x86_64' to 'Android:armv7'

Conan pip installation: C:\Python27amd64\Scripts>conan --version Conan version 1.6.1

Conan install Gradle task in Android Studio 3.1.3:

task conanInstall {
    def buildDir = new File("app/conan_build")
    buildDir.mkdirs()
    // if you have problems running the command try to specify the absolute
    // path to conan (Known problem in MacOSX) /usr/local/bin/conan
    def cmmd = "conan install ../conanfile.txt --profile android_21_arm_clang --build missing --env CONAN_CMAKE_GENERATOR=\"Android Gradle - Ninja\""
    print(">> ${cmmd} \n")

    def sout = new StringBuilder(), serr = new StringBuilder()
    def proc = cmmd.execute(null, buildDir)
    proc.consumeProcessOutput(sout, serr)
    proc.waitFor()
    println "$sout $serr"
    if(proc.exitValue() != 0){
        throw new Exception("out> $sout err> $serr" + "\nCommand: ${cmmd}")
    }
}

I pass the "Android Gradle - Ninja" to prevent Conan to choose the MinGW builder. Here is my profile, it is like in Conan tutorial: android_21_arm_clang.txt

The CMake is from Android SDK. (3.6.4111459)

Here is the output:

out> zlib/1.2.11@conan/stable: WARN: Package is corrupted, removing folder: C:\Users\Konstantin\.conan\data\zlib\1.2.11\conan\stable\package\39a53587004d75943e385925ca011baeab537de0
PROJECT: Installing C:\Work\git\tbh\dev\client\android\app\conanfile.txt
Requirements
    zlib/1.2.11@conan/stable from 'conan-center' - Cache
Packages
    zlib/1.2.11@conan/stable:39a53587004d75943e385925ca011baeab537de0 - Build

Cross-build from 'Windows:x86_64' to 'Android:armv7'
zlib/1.2.11@conan/stable: Building your package in C:\Users\Konstantin\.conan\data\zlib\1.2.11\conan\stable\build\39a53587004d75943e385925ca011baeab537de0
zlib/1.2.11@conan/stable: Copying sources to build folder
zlib/1.2.11@conan/stable: Generator cmake created conanbuildinfo.cmake
zlib/1.2.11@conan/stable: Calling build()
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: C:/Work/SDKs/Android/android-sdk/ndk-bundle/build/tools/mytoolchains/arm_21_toolchain/bin/arm-linux-androideabi-clang
-- Check for working C compiler: C:/Work/SDKs/Android/android-sdk/ndk-bundle/build/tools/mytoolchains/arm_21_toolchain/bin/arm-linux-androideabi-clang -- broken
-- Configuring incomplete, errors occurred!
See also "C:/Users/Konstantin/.conan/data/zlib/1.2.11/conan/stable/build/39a53587004d75943e385925ca011baeab537de0/zlib-1.2.11/_build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Konstantin/.conan/data/zlib/1.2.11/conan/stable/build/39a53587004d75943e385925ca011baeab537de0/zlib-1.2.11/_build/CMakeFiles/CMakeError.log".
zlib/1.2.11@conan/stable: 
zlib/1.2.11@conan/stable: ERROR: Package '39a53587004d75943e385925ca011baeab537de0' build failed
zlib/1.2.11@conan/stable: WARN: Build folder C:\Users\Konstantin\.conan\data\zlib\1.2.11\conan\stable\build\39a53587004d75943e385925ca011baeab537de0
ERROR: zlib/1.2.11@conan/stable: Error in build() method, line 71
    cmake.configure(build_dir=".")
    ConanException: Error 1 while executing cd . && cmake -G "Android Gradle - Ninja" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_SYSTEM_NAME="Android" -DCMAKE_SYSTEM_VERSION="21" -DCONAN_CMAKE_FIND_ROOT_PATH="C:/Work/SDKs/Android/android-sdk/ndk-bundle/build/tools/mytoolchains/arm_21_toolchain/sysroot" -DCMAKE_SYSROOT="C:/Work/SDKs/Android/android-sdk/ndk-bundle/build/tools/mytoolchains/arm_21_toolchain/sysroot" -DCMAKE_ANDROID_ARCH_ABI="armeabi-v7a" -DCONAN_EXPORTED="1" -DCONAN_COMPILER="clang" -DCONAN_COMPILER_VERSION="5.0" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="C:\Users\Konstantin\.conan\data\zlib\1.2.11\conan\stable\package\39a53587004d75943e385925ca011baeab537de0" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -Wno-dev C:\Users\Konstantin\.conan\data\zlib\1.2.11\conan\stable\build\39a53587004d75943e385925ca011baeab537de0
err> CMake Error at C:/Work/SDKs/Android/android-sdk/cmake/3.6.4111459/share/cmake-3.6/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler
"C:/Work/SDKs/Android/android-sdk/ndk-bundle/build/tools/mytoolchains/arm_21_toolchain/bin/arm-linux-androideabi-clang"
is not able to compile a simple test program.

It fails with the following output:

Change Dir: C:/Users/Konstantin/.conan/data/zlib/1.2.11/conan/stable/build/39a53587004d75943e385925ca011baeab537de0/zlib-1.2.11/_build/CMakeFiles/CMakeTmp

Run Build
Command:"C:/Work/SDKs/Android/android-sdk/cmake/3.6.4111459/bin/ninja.exe"
"cmTC_de049"

[1/2] Building C object CMakeFiles\cmTC_de049.dir\testCCompiler.c.o

ninja: fatal: CreateProcess: %1 не является приложением Win32.

Here are the CMake logs from zlib-1.2.11_build\CMakeFiles folder:

CMakeError.log CMakeOutput.log

The string %1 не является приложением Win32 is the same: %1 is not a valid Win32 application

Hope this helps to fix build for Android on Windows.

raffienficiaud commented 6 years ago

Slightly related to this: https://gitlab.kitware.com/cmake/cmake/issues/18342 Pointing to the NDK and using NMake generator on cmake seems to do the work.

memsharded commented 1 year ago

Outdated issue, visit https://docs.conan.io/2/examples/cross_build/android/ndk.html for updated 2.0 tutorial