conan入门:Windows NDK 编译 boost报错:CMake was unable to find a build program .... MinGW Makefile
Posted 10km
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了conan入门:Windows NDK 编译 boost报错:CMake was unable to find a build program .... MinGW Makefile相关的知识,希望对你有一定的参考价值。
conan NDK 编译 boost报错:CMake was unable to find a build program corresponding to “MinGW Makefiles”
今天在Windows平台如下正常执行conan NDK交叉编译Boost库时报了个错
$ conan install boost/1.69.0@ -pr:h android_21_armv7a_clang -pr:b default --build missing
错误日志如下,看样子是在编译依赖库bzip2时出错了,还没到编译boost的阶段
bzip2/1.0.8: Configuring sources in C:\\Users\\gyd\\.conan\\data\\bzip2\\1.0.8\\_\\_\\source
Downloading bzip2-1.0.8.tar.gz completed [791.04k]
bzip2/1.0.8: Copying sources to build folder
bzip2/1.0.8: Building your package in C:\\Users\\gyd\\.conan\\data\\bzip2\\1.0.8\\_\\_\\build\\deac87feb545b6b90ea1825dffccbb58b211ca1b
bzip2/1.0.8: Generator cmake created conanbuildinfo.cmake
bzip2/1.0.8: Aggregating env generators
bzip2/1.0.8: 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
-- Configuring incomplete, errors occurred!
bzip2/1.0.8:
bzip2/1.0.8: ERROR: Package 'deac87feb545b6b90ea1825dffccbb58b211ca1b' build failed
bzip2/1.0.8: WARN: Build folder C:\\Users\\gyd\\.conan\\data\\bzip2\\1.0.8\\_\\_\\build\\deac87feb545b6b90ea1825dffccbb58b211ca1b
ERROR: bzip2/1.0.8: Error in build() method, line 67
cmake = self._configure_cmake()
while calling '_configure_cmake', line 61
self._cmake.configure()
ConanException: Error 1 while executing cd C:\\Users\\gyd\\.conan\\data\\bzip2\\1.0.8\\_\\_\\build\\deac87feb545b6b90ea1825dffccbb58b211ca1b && cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_TOOLCHAIN_FILE="C:\\android-ndk-r19c\\build\\cmake\\android.toolchain.cmake" -DCONAN_IN_LOCAL_CACHE="ON" -DCONAN_COMPILER="clang" -DCONAN_COMPILER_VERSION="8" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="C:\\Users\\gyd\\.conan\\data\\bzip2\\1.0.8\\_\\_\\package\\deac87feb545b6b90ea1825dffccbb58b211ca1b" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCONAN_CMAKE_POSITION_INDEPENDENT_CODE="ON" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -DBZ2_VERSION_STRING="1.0.8" -DBZ2_VERSION_MAJOR="1" -DBZ2_BUILD_EXE="True" -Wno-dev C:\\Users\\gyd\\.conan\\data\\bzip2\\1.0.8\\_\\_\\build\\deac87feb545b6b90ea1825dffccbb58b211ca1b
似乎是需要MinGW编译器啊,刚才开始我的解决方法,就是装个MinGW编译器,将C:\\mingw64\\bin
设置到环境变量PATH
,然后就解决了这个问题。
但我还是觉得不太对,Android NDK交叉编译为什么需要MinGW(mingw64 )编译器呢?这不合理啊。
在Conan issue找到了同款问题:
《Some CMake Settings Passed On With Build Missing on Cross Build #3884》
真正的原因是没有指定CMake的GENERATOR,导致某些库的编译脚本误定义为MinGW Makefiles
,下面是解决方法:
就是需要设置环境变量CONAN_CMAKE_GENERATOR
为Unix Makefiles
可以如下在命令行临时设置环境变量:
set CONAN_CMAKE_GENERATOR=Unix Makefiles
也可以如下将它添加到profile,注意这里Unix Makefiles
需要加引号("
)
android_armv7a_clang
include(default)
android_ndk=D:\\j\\android-ndk-r19c
target_host=armv7a-linux-androideabi
api_level=16
[settings]
arch=armv7
build_type=Release
compiler=clang
compiler.libcxx=c++_static
#compiler.libcxx=c++_shared
compiler.version=8
os=Android
os.api_level=$api_level
#[tool_requires]
[options]
addr2line_location=$android_ndk\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\x86_64-linux-android-addr2line.exe
[env]
PATH=[$android_ndk\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin]
CHOST=$target_host
AR=arm-linux-androideabi-ar
AS=arm-linux-androideabi-as
RANLIB=arm-linux-androideabi-ranlib
CC=$target_host$api_level-clang.cmd
CXX=$target_host$api_level-clang++.cmd
LD=arm-linux-androideabi-ld
STRIP=arm-linux-androideabi-strip
CONAN_CMAKE_TOOLCHAIN_FILE=$android_ndk\\build\\cmake\\android.toolchain.cmake
CONAN_CMAKE_GENERATOR="Unix Makefiles"
[conf]
tools.android:ndk_path=$android_ndk
CONAN_CMAKE_GENERATOR与上面profile中的CONAN_CMAKE_TOOLCHAIN_FILE一样都是conan自定义的环境变量,
关于conan 环境变量的说明参见Conan官方文档《Environment variables》
conan系列文章
《conan入门(一):conan 及 JFrog Artifactory 安装》
《conan入门(二):conan 服务配置-密码管理及策略》
《conan入门(三):上传预编译的库(artifact)》
《conan入门(四):conan 引用第三方库示例》
《conan入门(五):conan 交叉编译引用第三方库示例》
《conan入门(六):conanfile.txt conanfile.py的区别》
《conan入门(七):将自己的项目生成conan包》
《conan入门(八):交叉编译自己的conan包项目》
《conan入门(九):NDK交叉编译自己的conan包项目塈profile的定义》
《conan入门(十):Windows下Android NDK交叉编译Boost》
《conan入门(十一):Linux下Android NDK交叉编译Boost》
《conan入门(十二):Windows NDK 编译 boost报错:CMake was unable to find a build program … MinGW Makefile》
以上是关于conan入门:Windows NDK 编译 boost报错:CMake was unable to find a build program .... MinGW Makefile的主要内容,如果未能解决你的问题,请参考以下文章
conan入门(十六):profile template功能实现不同平台下profile的统一
conan入门(十七):支持android NDK (armv7,armv8,x86,x86_64)交叉编译的统一profile jinja2模板
conan入门(十八):Cannot recognize the Windows subsystem, install MSYS2/cygwin or specify a build_require