Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

building android project produces make error 2

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:\ndk\android-ndk-r9\ndk-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:\ndk\android-ndk-r9\'.

like image 339
Matthew Spencer Avatar asked Oct 20 '13 12:10

Matthew Spencer


1 Answers

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).

like image 172
Sergey K. Avatar answered Sep 20 '22 00:09

Sergey K.