Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have recently purchased a book to assist in my development of C++ for Android which contained some code samples. However, when I come to build some of the sample code, I receive the following error:

C:
dkandroid-ndk-r9
dk-build.cmd all 
"Compile++  : Chapter10 <= Chapter10.cpp
process_begin: CreateProcess(NULL, C:/ndk/android-ndk-r9/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin/arm-linux-androideabi-g++ -MMD -MP -MF ./obj/local/armeabi/objs/Chapter10/Chapter10.o.d -fno-exceptions -fno-rtti -Ijni -IC:/ndk/android-ndk-r9/sources/android/native_app_glue -IC:/ndk/android-ndk-r9/sources/cxx-stl/stlport/stlport -IC:/ndk/android-ndk-r9/sources/cxx-stl//gabi++/include -Ijni -DANDROID -Wa,--noexecstack -Wformat -Werror=format-security -frtti -c jni/Chapter10.cpp -o ./obj/local/armeabi/objs/Chapter10/Chapter10.o, ...) failed.

make (e=2): The system cannot find the file specified.

make: *** [obj/local/armeabi/objs/Chapter10/Chapter10.o] Error 2

The make file is as shown below:

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_ARM_MODE          := arm
LOCAL_C_INCLUDES        := $(LOCAL_PATH)
LOCAL_MODULE            := Chapter10
LOCAL_SRC_FILES         := Chapter10.cpp 
                           (Other cpp Files . . . )
LOCAL_LDLIBS            := -llog -landroid -lEGL -lGLESv2 -lOpenSLES
LOCAL_STATIC_LIBRARIES  := android_native_app_glue

include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/native_app_glue)

The Application.mk file is as below:

APP_PLATFORM    := android-9
APP_STL         := stlport_static
NDK_TOOLCHAIN_VERSION   := 4.7

This was compiled using ADT v22.2.1 and Android NDK r9 on a Windows 7 Machine.

The NDK was installed to 'C: dkandroid-ndk-r9'.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
384 views
Welcome To Ask or Share your Answers For Others

1 Answer

Android NDK r9 contains the following toolchains:

  1. arm-linux-androideabi-4.6
  2. arm-linux-androideabi-4.8
  3. arm-linux-androideabi-clang3.2
  4. arm-linux-androideabi-clang3.3
  5. llvm-3.2
  6. llvm-3.3
  7. mipsel-linux-android-4.6
  8. mipsel-linux-android-4.8
  9. mipsel-linux-android-clang3.2
  10. mipsel-linux-android-clang3.3
  11. x86-4.6
  12. x86-4.8
  13. x86-clang3.2
  14. x86-clang3.3

There is no toolchain for gcc 4.7. However, your Application.mk contains the line:

NDK_TOOLCHAIN_VERSION   := 4.7

Which tells the NDK to look for the 4.7 toolchain. And it fails.

So, the solution to your problem is changing the NDK_TOOLCHAIN_VERSION variable to 4.6, 4.8, clang3.2, clang3.3, or just clang (which will use the most recent version of Clang available in the NDK).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...