我正在尝试构建 android NDK,它给了我这个错误。 我正在使用 eclipse 。 我正在使用 android-ndk-r12。 eclipse 中的 Android NDK 首选项是 C:\android-ndk-r12(我也尝试过“C:\android-ndk-r12\build”,但没有用)。 android Android.mk 如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := com_example_ndktest_Store
LOCAL_SRC_FILES := com_example_ndktest_Store.cpp
include $(BUILD_SHARED_LIBRARY)
错误如下:
[armeabi-v7a] "Compile++ arm ": "com_example_ndktesting_Store <= com_example_ndktesting_Store.cpp"
process_begin: CreateProcess(NULL, C:/android-ndk-r12/build//../toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -MMD -MP -MF ./obj/local/armeabi-v7a/objs/com_example_ndktesting_Store/com_example_ndktesting_Store.o.d -gcc-toolchain C:/android-ndk-r12/build//../toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64 -fpic -ffunction-sections -funwind-tables -fstack-protector-strong -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -fno-integrated-as -g -target armv7-none-linux-androideabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-exceptions -fno-rtti -marm -O2 -DNDEBUG -IC:/android-ndk-r12/build//../sources/cxx-stl/gnu-libstdc++/4.9/include -IC:/android-ndk-r12/build//../sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -IC:/android-ndk-r12/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/backward -Ijni -DANDROID -mfpu=vfp -mfloat-abi=softfp -fno-short-enums -Werror -DANDROID -DDISABLE_IMPORTGL -isystem /usr/include/ -Wa,--noexecstack -Wformat -Werror=format-security -std=gnu++0x -frtti -fexceptions -DANDROID -isystem C:/android-ndk-r12/build//../platforms/android-24/arch-arm/usr/include -c jni/com_example_ndktesting_Store.cpp -o ./obj/local/armeabi-v7a/objs/com_example_ndktesting_Store/com_example_ndktesting_Store.o, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [obj/local/armeabi-v7a/objs/com_example_ndktesting_Store/com_example_ndktesting_Store.o] Error 2
最佳答案
1- 确保您拥有正确版本的 NDK: 如果您使用 32 位 Windows,则应下载并安装 android-ndk-r12-windows-x86.zip;如果您使用 64 位 Windows,则应下载并安装 android-ndk-r12-windows-x86_64.zip
2- 定义适当的工具链: 您确定在指定路径中找到了 clang++.exe,这个 ndk 版本是否有这个工具链? 尝试将 Android.mk 文件中的 NDK_TOOLCHAIN_VERSION(例如 NDK_TOOLCHAIN_VERSION := clang3.3)设置为在 ndk-r12 中找到的正确工具链。 Android 开发者文档:
NDK_TOOLCHAIN_VERSION
Define this variable as either 4.9 or 4.8 to select a version of the GCC compiler. Version 4.9 is the default for 64-bit ABIs, and 4.8 is the default for 32-bit ABIs. To select a version of Clang, define this variable as clang3.4, clang3.5, or clang. Specifying clang chooses the most recent version of Clang.
关于Android NDK 给出了这个错误 make Error 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38630642/