为Eclipse教程构建NDK库时出错

时间:2013-12-09 13:04:49

标签: eclipse android-ndk shared-libraries build-error

我在成熟的XP(SP3)系统上安装了Eclipse(v22.3.0-887826),Andriod NDK R9B和Cygwin(v 1.7.27)。全部安装无事故。作为其他学科的经验丰富的开发人员,我立即开始在IDE中构建我的第一个应用程序。一切顺利,直到我无法创建共享库。所以我去了教程并导入'Hello-jni'作为现有代码,并按照指定设置ndk-build。创建共享库时的构建错误:     /cygdrive/c/Android-ndk-r9b/build/core/build-binary.mk:577:目标'/cygdrive/C/Android/workspace/hellojni/obj/local/armeabi/libhello-jni.so'的食谱失败

我在清单中设置android:debuggable =“false”作为第一个错误引用输出到调试子目录。 -clean和-B选项也进行了测试。

构建的输出: Larry @ eros / cygdrive / c / android / workspace / hellojni $ $ NDK / ndk-build V = 1

rm -f /cygdrive/C/Android/workspace/hellojni/libs/armeabi/lib*.so /cygdrive/C/Android/workspace/hellojni/libs/armeabi-v7a/lib*.so /cygdrive/C/Android/workspace/hellojni/libs/mips/lib*.so /cygdrive/C/Android/workspace/hellojni/libs/x86/lib*.so
rm -f /cygdrive/C/Android/workspace/hellojni/libs/armeabi/gdbserver /cygdrive/C/Android/workspace/hellojni/libs/armeabi-v7a/gdbserver /cygdrive/C/Android/workspace/hellojni/libs/mips/gdbserver /cygdrive/C/Android/workspace/hellojni/libs/x86/gdbserver
rm -f /cygdrive/C/Android/workspace/hellojni/libs/armeabi/gdb.setup /cygdrive/C/Android/workspace/hellojni/libs/armeabi-v7a/gdb.setup /cygdrive/C/Android/workspace/hellojni/libs/mips/gdb.setup /cygdrive/C/Android/workspace/hellojni/libs/x86/gdb.setup
[armeabi] Compile thumb  : hello-jni <= hello-jni.c
/cygdrive/c/Android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-gcc -MMD -MP -MF C:/Android/workspace/hellojni/obj/local/armeabi/objs/hello-jni/hello-jni.o.d.org -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -IC:/Android/workspace/hellojni/jni -DANDROID  -Wa,--noexecstack -Wformat -Werror=format-security    -IC:/Android-ndk-r9b/platforms/android-16/arch-arm/usr/include -c  C:/Android/workspace/hellojni/jni/hello-jni.c -o C:/Android/workspace/hellojni/obj/local/armeabi/objs/hello-jni/hello-jni.o && /cygdrive/C/Android/workspace/hellojni/obj/convert-dependencies.sh C:/Android/workspace/hellojni/obj/local/armeabi/objs/hello-jni/hello-jni.o.d
[armeabi] SharedLibrary  : libhello-jni.so
/cygdrive/c/Android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-g++ -Wl,-soname,libhello-jni.so -shared --sysroot=C:/Android-ndk-r9b/platforms/android-16/arch-arm C:/Android/workspace/hellojni/obj/local/armeabi/objs/hello-jni/hello-jni.o -lgcc -no-canonical-prefixes  -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now   -lc -lm -o C:/Android/workspace/hellojni/obj/local/armeabi/libhello-jni.so
/cygdrive/c/Android-ndk-r9b/build/core/build-binary.mk:577: recipe for target '/cygdrive/C/Android/workspace/hellojni/obj/local/armeabi/libhello-jni.so' failed

从$ env输出:

HOMEPATH=\Documents and Settings\Larry
MANPATH=/usr/local/man:/usr/share/man:/usr/man::/usr/ssl/man
NDK=/cygdrive/c/Android-ndk-r9b
APPDATA=C:\Documents and Settings\Larry\Application Data
HOSTNAME=eros
SHELL=/bin/bash
TERM=xterm
PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 9, GenuineIntel
ANDROID_SDK_PATH=/cygdrive/c/Android/adt-bundle-windows-x86-20131030
WINDIR=C:\WINDOWS
ANDROID_SDK_ROOT=C:\Android\adt-bundle-windows-x86-20131030
OLDPWD=/home/Larry
ClassicVB-lm=Rocks!
USERDOMAIN=EROS
OS=Windows_NT
ALLUSERSPROFILE=C:\Documents and Settings\All Users
ANT_HOME=C:\Android\apache-ant-1.9.2-bin\apache-ant-1.9.2
$NDK_PROJECT_PATH=/cygdrive/c/Android/workspace/hellojni
$NDK_ROOT=/cygdrive/c/android-ndk-r9b
USER=Larry
TEMP=/tmp
temp=C:\DOCUME~1\Larry\LOCALS~1\Temp
COMMONPROGRAMFILES=C:\Program Files\Common Files
tmp=C:\DOCUME~1\Larry\LOCALS~1\Temp
ANDROID_NDK_ROOT=C:\android-ndk-r9b
QTJAVA=C:\Program Files\Java\jre7\lib\ext\QTJava.zip
USERNAME=Larry
PROCESSOR_LEVEL=15
PATH=/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Borland/Delphi7/Bin:/cygdrive/c/Program Files/Borland/Delphi7/Projects/Bpl:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS/system32/WBEM:/cygdrive/c/PsTools:/cygdrive/c/Program Files/Common Files/Adobe/AGL:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn:/cygdrive/c/FPC/2.4.2/bin/i386-Win32:/cygdrive/c/Program Files/QuickTime/QTSystem:/cygdrive/c/Android/apache-ant-1.9.2-bin/apache-ant-1.9.2
FP_NO_HOST_CHECK=NO
PWD=/cygdrive/c/android/workspace/hellojni
SYSTEMDRIVE=C:
GNUMAKE=/usr/bin/make
VBROKERDIR=C:\Inprise\vbroker
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_45
LANG=en_US.UTF-8
USERPROFILE=C:\Documents and Settings\Larry
CLIENTNAME=Console
TZ=America/Los_Angeles
PS1=\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$
LOGONSERVER=\\EROS
ARM_PATH=/cygdrive/C/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin
ClassicVB-cu=Rocks!
ANDROID_NDK_PATH=/cygdrive/c/andriod-ndk-r9b
PROCESSOR_ARCHITECTURE=x86
SHLVL=1
HOME=/home/Larry
$NDK=/cygdrive/c/Android-ndk-r9b
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
HOMEDRIVE=C:
COMSPEC=C:\WINDOWS\system32\cmd.exe
TMP=/tmp
SYSTEMROOT=C:\WINDOWS
PRINTER=HP LaserJet 1100 (MS)
PROCESSOR_REVISION=0209
CLASSPATH=.;C:\Program Files\Java\jre7\lib\ext\QTJava.zip
INFOPATH=/usr/local/info:/usr/share/info:/usr/info:
PROGRAMFILES=C:\Program Files
NUMBER_OF_PROCESSORS=2
NDK_PROJECT_PATH=/cygdrive/C/Android/workspace/hellojni
NDK_ROOT=/cygdrive/c/Android-ndk-r9b
SESSIONNAME=Console
COMPUTERNAME=EROS
_=/usr/bin/env

最后,NDK_LOG的输出= 1:

HOST_OS=cygwin
HOST_ARCH=x86
HOST_TAG=cygwin-x86 
GNUMAKE=/usr/bin/make (from environment variable)
Cygwin-compatible GNU make detected
Android NDK: NDK installation path auto-detected: '/cygdrive/c/Android-ndk-r9b'
Android NDK: GNU Make version 4.0 detected
Android NDK: Host OS was auto-detected: windows
Android NDK: Found /bin/uname.exe on Windows host
Android NDK: uname -s returned: CYGWIN_NT-5.1
Android NDK: Cygwin detected: CYGWIN_NT-5.1 eros 1.7.25(0.270/5/3) 2013-08-31 20:39 i686 Cygwin
Android NDK:  Host operating system detected: cygwin
Android NDK: Host CPU was auto-detected: x86
Android NDK: HOST_TAG set to windows
Android NDK: Host tools prebuilt directory: /cygdrive/c/Android-ndk-r9b/prebuilt/windows/bin
Android NDK: Host 'echo' tool: echo
Android NDK: Host 'echo -n' tool: printf %s
Android NDK: Host 'cmp' tool: /cygdrive/c/Android-ndk-r9b/prebuilt/windows/bin/cmp
Android NDK: Host 'awk' tool: awk
Android NDK: Host 'awk' test returned: Pass
Android NDK:  Probing for 'cygpath' program
Android NDK:  'cygpath' found as: /usr/bin/cygpath
Using cygwin substitution rules:
/cygdrive/f => F:
/cygdrive/c => C:
/cygdrive/F => F:
/cygdrive/C => C:
/usr/lib => C:/cygwin/lib
/usr/bin => C:/cygwin/bin
/ => C:/cygwin
Android NDK: Found platform root directory: /cygdrive/c/Android-ndk-r9b/platforms
Android NDK: Found supported platforms: android-4 android-17 android-18 android-19 android-13 android-3 android-14 android-15 android-8 android-9 android-16 android-5
Android NDK: PLATFORM android-4 supports: arm
Android NDK:   ABI arm sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-4/arch-arm
Android NDK: PLATFORM android-17 supports: x86 arm mips
Android NDK:   ABI x86 sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-17/arch-x86
Android NDK:   ABI arm sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-17/arch-arm
Android NDK:   ABI mips sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-17/arch-mips
Android NDK: PLATFORM android-18 supports: x86 arm mips
Android NDK:   ABI x86 sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-18/arch-x86
Android NDK:   ABI arm sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-18/arch-arm
Android NDK:   ABI mips sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-18/arch-mips
Android NDK: PLATFORM android-19 supports: x86 arm mips
Android NDK:   ABI x86 sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-19/arch-x86
Android NDK:   ABI arm sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-19/arch-arm
Android NDK:   ABI mips sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-19/arch-mips
Android NDK: PLATFORM android-13 supports: x86 arm mips
Android NDK:   ABI x86 sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-13/arch-x86
Android NDK:   ABI arm sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-13/arch-arm
Android NDK:   ABI mips sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-13/arch-mips
Android NDK: PLATFORM android-3 supports: arm
Android NDK:   ABI arm sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-3/arch-arm
Android NDK: PLATFORM android-14 supports: x86 arm mips
Android NDK:   ABI x86 sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-14/arch-x86
Android NDK:   ABI arm sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-14/arch-arm
Android NDK:   ABI mips sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-14/arch-mips
Android NDK: PLATFORM android-15 supports: x86 arm mips
Android NDK:   ABI x86 sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-15/arch-x86
Android NDK:   ABI arm sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-15/arch-arm
Android NDK:   ABI mips sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-15/arch-mips
Android NDK: PLATFORM android-8 supports: arm
Android NDK:   ABI arm sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-8/arch-arm
Android NDK: PLATFORM android-9 supports: x86 arm mips
Android NDK:   ABI x86 sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-9/arch-x86
Android NDK:   ABI arm sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-9/arch-arm
Android NDK:   ABI mips sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-9/arch-mips
Android NDK: PLATFORM android-16 supports: x86 arm mips
Android NDK:   ABI x86 sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-16/arch-x86
Android NDK:   ABI arm sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-16/arch-arm
Android NDK:   ABI mips sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-16/arch-mips
Android NDK: PLATFORM android-5 supports: arm
Android NDK:   ABI arm sysroot is: /cygdrive/c/Android-ndk-r9b/platforms/android-5/arch-arm
Android NDK: Found stable platform levels: 4 17 18 19 13 3 14 15 8 9 16 5
Android NDK: Found max platform level: 19
Android NDK:  This NDK supports the following target architectures and ABIS:
Android NDK:    arm: armeabi armeabi-v7a
Android NDK:    mips: mips
Android NDK:    x86: x86
Android NDK:  This NDK supports the following toolchains and target ABIs:
Android NDK:    arm-linux-androideabi-4.6:  armeabi armeabi-v7a
Android NDK:    arm-linux-androideabi-4.8:  armeabi armeabi-v7a
Android NDK:    arm-linux-androideabi-clang3.3:  armeabi armeabi-v7a
Android NDK:    mipsel-linux-android-4.6:  mips
Android NDK:    mipsel-linux-android-4.8:  mips
Android NDK:    mipsel-linux-android-clang3.3:  mips
Android NDK:    x86-4.6:  x86
Android NDK:    x86-4.8:  x86
Android NDK:    x86-clang3.3:  x86
Android NDK: Found project path: /cygdrive/C/Android/workspace/hellojni
Android NDK: Ouput path: /cygdrive/C/Android/workspace/hellojni/obj
Android NDK: Parsing /cygdrive/c/Android-ndk-r9b/build/core/default-application.mk
Android NDK:   Found APP_PLATFORM=android-16 in /cygdrive/C/Android/workspace/hellojni/project.properties
Android NDK:   APP_PIE is 
Android NDK:   Enabling -fPIE
Android NDK:   Using build script /cygdrive/C/Android/workspace/hellojni/jni/Android.mk
Android NDK: Application 'local' is not debuggable
Android NDK: Selecting release optimization mode (app is not debuggable)
Android NDK: Adding import directory: /cygdrive/c/Android-ndk-r9b/sources
Android NDK: Building application 'local' for ABI 'armeabi'
Android NDK: Using target toolchain 'arm-linux-androideabi-4.6' for 'armeabi' ABI
Android NDK: Looking for imported module with tag 'cxx-stl/system'
Android NDK:   Probing /cygdrive/c/Android-ndk-r9b/sources/cxx-stl/system/Android.mk
Android NDK:     Found in /cygdrive/c/Android-ndk-r9b/sources/cxx-stl/system
Android NDK: [armeabi] Modules to build: hello-jni
Android NDK: Cygwin dependency file conversion script:    
----- start of script ----
#!/bin/sh # AUTO-GENERATED FILE, DO NOT EDIT! if [ -f $1.org ]; then   sed -e 's!^C:/cygwin/lib!/usr/lib!ig;s! C:/cygwin/lib! /usr/lib!ig;s!^C:/cygwin/bin!/usr/bin!ig;s! C:/cygwin/bin! /usr/bin!ig;s!^C:/cygwin/!/!ig;s! C:/cygwin/! /!ig;s!^F:!/cygdrive/f!ig;s! F:! /cygdrive/f!ig;s!^C:!/cygdrive/c!ig;s! C:! /cygdrive/c!ig;' $1.org > $1 && rm -f $1.org fi
------ end of script -----
[armeabi] Compile thumb  : hello-jni <= hello-jni.c
[armeabi] SharedLibrary  : libhello-jni.so
/cygdrive/c/Android-ndk-r9b/build/core/build-binary.mk:577: recipe for target '/cygdrive/C/Android/workspace/hellojni/obj/local/armeabi/libhello-jni.so' failed

我花了几天时间试图自己解决这个问题。我现在已经重新安装了三次,只是看不出问题。任何有关此事的帮助将不胜感激。 感谢。

2 个答案:

答案 0 :(得分:0)

工具链似乎生成了文件: C:/Android/workspace/hellojni/obj/local/armeabi/libhello-jni.so 但失败了,因为配方应该是: /cygdrive/C/Android/workspace/hellojni/obj/local/armeabi/libhello-jni.so

虽然这两个代表完全相同的文件,但它似乎不起作用。 您可以尝试将所有env路径切换为/ cygdrive / notation,也可以只删除cygwin。您通常不需要使用cygwin来使用Android NDK,它已经有一个完整的独立工具链可以更好地工作。

答案 1 :(得分:0)

最后 - 在对我的内部知识库进行大量审查和回收之后,这个问题的解决方案不是一个过载的PC(我的确定),也没有用于编译和链接的可用内存。 Windows(C:...)和Cygwin(/ cygdrive / c / ...)之间的环境路径差异也不是问题。该解决方案仅在将NDK和项目加载到旧笔记本电脑上后才出现,并从头开始。解决方案:在初始构建和后续问题报告期间未设置NDK_PROJECT_PATH。设置为// cygdrive / c / projectname / jni后,构建按预期进行