[英]How to fix "Could not find toolchain file" "CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage" cmake libjpeg-turbo.so?
I am working on generating libjpeg-turbo.so files for different CPU architectures.我正在为不同的 CPU 架构生成 libjpeg-turbo.so 文件。
If I execute the below cmake in my build folder I am getting this error even though the toolchain file is present in that path:如果我在构建文件夹中执行以下 cmake,即使该路径中存在工具链文件,我也会收到此错误:
$ cmake -G"Unix Makefiles" \
-DANDROID_ABI=arm64-v8a \
-DANDROID_ARM_MODE=arm \
-DANDROID_PLATFORM=android-${21} \
-DANDROID_TOOLCHAIN=${gcc} \
-DCMAKE_ASM_FLAGS="--target=aarch64-linux-android${21}" \
-DCMAKE_TOOLCHAIN_FILE=$/home/ingrid/Android/android-ndk-r16b/build/cmake/android.toolchain.cmake \
/home/ingrid/Ingrid/NeoReader/libjpeg-turbo-master/
Output:输出:
CMake Error at /usr/share/cmake-3.5/Modules/CMakeDetermineSystem.cmake:104 (message):
Could not find toolchain file:
$/home/ingrid/Android/android-ndk-r16b/build/cmake/android.toolchain.cmake
Call Stack (most recent call first):
CMakeLists.txt:7 (project)
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
However, if I remove -DANDROID_TOOLCHAIN=${gcc} \
and -DCMAKE_TOOLCHAIN_FILE=$/home/ingrid/Android/android-ndk-r16b/build/cmake/android.toolchain.cmake \
then I am able to generate the .so file but it is generating of x86_64 and not arm64_v8a.但是,如果我删除-DANDROID_TOOLCHAIN=${gcc} \
和-DCMAKE_TOOLCHAIN_FILE=$/home/ingrid/Android/android-ndk-r16b/build/cmake/android.toolchain.cmake \
那么我就可以生成 .so文件,但它生成的是 x86_64 而不是 arm64_v8a。 The below is the cmake and output for it:下面是它的 cmake 和输出:
$ cmake -G"Unix Makefiles" \
-DANDROID_ABI=arm64-v8a \
-DANDROID_ARM_MODE=arm \
-DANDROID_PLATFORM=android-${21} \
-DCMAKE_ASM_FLAGS="--target=aarch64-linux-android${21}" \
/home/ingrid/Ingrid/NeoReader/libjpeg-turbo-master/
Output:输出:
-- The C compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- CMAKE_BUILD_TYPE = Release
-- VERSION = 2.0.3, BUILD = 20190707
-- 64-bit build (x86_64)
-- CMAKE_INSTALL_PREFIX = /opt/libjpeg-turbo
-- CMAKE_INSTALL_BINDIR = bin (/opt/libjpeg-turbo/bin)
-- CMAKE_INSTALL_DATAROOTDIR = (/opt/libjpeg-turbo)
-- CMAKE_INSTALL_DOCDIR = doc (/opt/libjpeg-turbo/doc)
-- CMAKE_INSTALL_INCLUDEDIR = include (/opt/libjpeg-turbo/include)
-- CMAKE_INSTALL_LIBDIR = lib64 (/opt/libjpeg-turbo/lib64)
-- CMAKE_INSTALL_MANDIR = man (/opt/libjpeg-turbo/man)
-- Shared libraries enabled (ENABLE_SHARED = 1)
-- Static libraries enabled (ENABLE_STATIC = 1)
-- 12-bit JPEG support disabled (WITH_12BIT = 0)
-- Arithmetic decoding support enabled (WITH_ARITH_DEC = 1)
-- Arithmetic encoding support enabled (WITH_ARITH_ENC = 1)
-- TurboJPEG API library enabled (WITH_TURBOJPEG = 1)
-- TurboJPEG Java wrapper disabled (WITH_JAVA = 0)
-- In-memory source/destination managers enabled (WITH_MEM_SRCDST = 1)
-- Emulating libjpeg API/ABI v6.2 (WITH_JPEG7 = 0, WITH_JPEG8 = 0)
-- libjpeg API shared library version = 62.3.0
-- Compiler flags = -O3 -DNDEBUG
-- Linker flags =
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of size_t
-- Check size of size_t - done
-- Check size of unsigned long
-- Check size of unsigned long - done
-- Performing Test HAVE_BUILTIN_CTZL
-- Performing Test HAVE_BUILTIN_CTZL - Success
-- Looking for include file locale.h
-- Looking for include file locale.h - found
-- Looking for include file stdlib.h
-- Looking for include file stdlib.h - found
-- Looking for include file sys/types.h
-- Looking for include file sys/types.h - found
-- Looking for memset
-- Looking for memset - found
-- Looking for memcpy
-- Looking for memcpy - found
-- Check size of unsigned char
-- Check size of unsigned char - done
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Performing Test INCOMPLETE_TYPES
-- Performing Test INCOMPLETE_TYPES - Success
-- Compiler supports pointers to undefined structures.
-- Performing Test RIGHT_SHIFT_IS_UNSIGNED
-- Performing Test RIGHT_SHIFT_IS_UNSIGNED - Failed
-- Performing Test __CHAR_UNSIGNED__
-- Performing Test __CHAR_UNSIGNED__ - Failed
-- Performing Test INLINE_WORKS
-- Performing Test INLINE_WORKS - Success
-- INLINE = __inline__ __attribute__((always_inline)) (FORCE_INLINE = 1)
-- Performing Test HAVE_VERSION_SCRIPT
-- Performing Test HAVE_VERSION_SCRIPT - Success
-- Linker supports GNU-style version scripts
-- CMAKE_EXECUTABLE_SUFFIX =
-- The ASM_NASM compiler identification is unknown
-- Found assembler: /usr/bin/nasm
-- CMAKE_ASM_NASM_COMPILER = /usr/bin/nasm
-- CMAKE_ASM_NASM_OBJECT_FORMAT = elf64
-- CMAKE_ASM_NASM_FLAGS = -DELF -D__x86_64__ -DPIC
-- SIMD extensions: x86_64 (WITH_SIMD = 1)
-- FLOATTEST = sse
-- RPM architecture = x86_64, DEB architecture = amd64
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
ANDROID_ABI
ANDROID_ARM_MODE
ANDROID_PLATFORM
CMAKE_ASM_FLAGS
-- Build files have been written to: /home/ingrid/Ingrid/NeoReader/libjpeg-turbo-master/build-arm64-v8a
Can you please let me know how to resolve this toolchain error so that I can generate the libjpeg-turbo.so file for the arm64-v8a architecture?你能告诉我如何解决这个工具链错误,以便我可以为 arm64-v8a 架构生成 libjpeg-turbo.so 文件吗?
Thank you.谢谢你。
The following argument in your cmake line is wrong:您的 cmake 行中的以下参数是错误的:
...
-DCMAKE_TOOLCHAIN_FILE=$/home/ingrid/Android/android-ndk-r16b/build/cmake/android.toolchain.cmake \
...
The $
symbol tells the system that what follows is an environment variable. $
符号告诉系统后面是一个环境变量。 So you should either use -DCMAKE_TOOLCHAIN_FILE=$HOME/...
or -DCMAKE_TOOLCHAIN_FILE=/home/ingrid/...
.因此,您应该使用-DCMAKE_TOOLCHAIN_FILE=$HOME/...
或-DCMAKE_TOOLCHAIN_FILE=/home/ingrid/...
。
I don't know the documentation where you got that line from, but it probably mentioned one of the options from above.我不知道您从哪里获得该行的文档,但它可能提到了上面的选项之一。
BTW, @Tsyvarev was right about his suggestion, he just didn't know the rationale behind it.顺便说一句,@Tsyvarev 对他的建议是正确的,他只是不知道背后的理由。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.