Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
397 views
in Technique[技术] by (71.8m points)

c++ - 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:
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

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

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...