简体   繁体   中英

strip command cannot be found by CMake Android toolchain for arm when running add_qt_android_apk

In my CMake project I use the android.toolchain.cmake.

I pass the following environment variables as defines:

export ANDROID_ABI="armeabi-v7a" # x86
export ANDROID_TOOLCHAIN_NAME="arm-linux-androideabi-4.9" # "x86-4.9"
export ANDROID_API_LEVEL="23"
export QT_DIR="$HOME/Qt/5.7/android_armv7"
export ANDROID_STANDALONE_TOOLCHAIN="$HOME/android-ndk-r12b/toolchains/arm-linux-androideabi-4.9/"
export ANDROID_PREFIX="sdk-android-armv7" # sdk-android-x86
export ANDROID_TARGET="armv7" # x86
export QTAV_LIB_DIR="lib_android_arm" # lib_android_x86

I pass the variables the following way:

cmake -DUSE_COMPRESSED_FILES=1 -DJAVA_HOME="/usr/java/default/" -DANDROID_SDK="$ANDROID_HOME" -DQT_ANDROID_SDK_ROOT="$ANDROID_HOME" -DQT_ANDROID_ANT="$ANT_PATH" -DCMAKE_MODULE_PATH="../cmake" -DCMAKE_PREFIX_PATH="$QT_DIR/lib/cmake" -DCMAKE_TOOLCHAIN_FILE=../cmake/android.toolchain.cmake -DANDROID_NDK="$HOME/android-ndk-r12b" -DCMAKE_BUILD_TYPE=Debug -DANDROID_ABI="$ANDROID_ABI" -DANDROID_TOOLCHAIN_NAME="$ANDROID_TOOLCHAIN_NAME" -DANDROID_STANDALONE_TOOLCHAIN="$ANDROID_STANDALONE_TOOLCHAIN" -DANDROID_NATIVE_API_LEVEL="$ANDROID_API_LEVEL" -DQT_DIR="$QT_DIR" -DANDROID_PREFIX="$ANDROID_PREFIX" -DANDROID_TARGET="$ANDROID_TARGET" -DQTAV_LIB_DIR="$QTAV_LIB_DIR" ../

cmake --build .

When "Stripping libraries to minimize size." it says: Command does not exist: /home/peter/android-ndk-r12b/toolchains/armeabi-v7a-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip

The path should be "arm-linux-androideabi-4.9" and not "armeabi-v7a-4.9". Why is the ANDROID_ABI used instead of the ANDROID_TOOLCHAIN_NAME?

I do not have these problems for x86:

export ANDROID_ABI="x86"
export ANDROID_TOOLCHAIN_NAME="x86-4.9"
export ANDROID_API_LEVEL="23"
export QT_DIR="$HOME/Qt5.7.0/5.7/android_x86"
export ANDROID_STANDALONE_TOOLCHAIN="$HOME/android-ndk-r12b/toolchains/x86-4.9/"
export ANDROID_PREFIX="sdk-android-x86"
export ANDROID_TARGET="x86"
export QTAV_LIB_DIR="lib_android_x86"

edit: The strip command is set by the android.toolchain.cmake file:

 set( CMAKE_STRIP        "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-strip${TOOL_OS_SUFFIX}"   CACHE PATH "strip" )

ANDROID_TOOLCHAIN_ROOT is set this way since I specified a NDK path:

# setup paths and STL for NDK
if( BUILD_WITH_ANDROID_NDK )
 set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" )

so I guess ANDROID_GCC_TOOLCHAIN_NAME must be wrong? ANDROID_NDK_TOOLCHAINS_SUBPATH starts with "prebuilt" so it is correct. ANDROID_NDK_TOOLCHAINS_PATH ends with "toolchains" so it is correct, too.

ANDROID_GCC_TOOLCHAIN_NAME is set if it is not Clang (which it is not):

set( ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )

so everything should work fine since my ANDROID_TOOLCHAIN_NAME has been specified as "arm-linux-androideabi-4.9" above but it does not.

edit2:

ANDROID_ABI is the value which is used instead. It is never used in any strip path as far as I can see it in the file "android.toolchain.cmake" but its value is copied to ANDROID_NDK_ABI_NAME as well which is neither used for any strip path.

edit3: It might be an error in AddQtAndroidApk.cmake rather than the toolchain since the output is actually:

Stripping libraries to minimize size.
Command does not exist: /home/peter/android-ndk-r12b/toolchains/armeabi-v7a-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip
CMakeFiles/my_app_apk.dir/build.make:60: recipe for target 'run_android_deploy_qt' failed

Somehow the file qtdeploy.json.in got the WRONG entry

"toolchain-prefix": "@ANDROID_ABI@",

which was no problem for x86. Of course it should be:

 "toolchain-prefix": "@ANDROID_TOOLCHAIN_MACHINE_NAME@",

Besides I removed the statement setting "ANDROID_STANDALONE_TOOLCHAIN" which is not necessary. I got the necessary information using

cmake -DCMAKE_VERBOSE_MAKEFILE=on ...
make VERBOSE=1

and looking at the Qt CMake package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM