为Eclipse教程构建NDK库时出错



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

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

生成的输出:Larry@eros/cygdrive/c/android/workspace/hellojni$$NDK/NDK构建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 SettingsLarry
MANPATH=/usr/local/man:/usr/share/man:/usr/man::/usr/ssl/man
NDK=/cygdrive/c/Android-ndk-r9b
APPDATA=C:Documents and SettingsLarryApplication 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:Androidadt-bundle-windows-x86-20131030
OLDPWD=/home/Larry
ClassicVB-lm=Rocks!
USERDOMAIN=EROS
OS=Windows_NT
ALLUSERSPROFILE=C:Documents and SettingsAll Users
ANT_HOME=C:Androidapache-ant-1.9.2-binapache-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~1LarryLOCALS~1Temp
COMMONPROGRAMFILES=C:Program FilesCommon Files
tmp=C:DOCUME~1LarryLOCALS~1Temp
ANDROID_NDK_ROOT=C:android-ndk-r9b
QTJAVA=C:Program FilesJavajre7libextQTJava.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:Inprisevbroker
JAVA_HOME=C:Program FilesJavajdk1.7.0_45
LANG=en_US.UTF-8
USERPROFILE=C:Documents and SettingsLarry
CLIENTNAME=Console
TZ=America/Los_Angeles
PS1=[e]0;wa]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:WINDOWSsystem32cmd.exe
TMP=/tmp
SYSTEMROOT=C:WINDOWS
PRINTER=HP LaserJet 1100 (MS)
PROCESSOR_REVISION=0209
CLASSPATH=.;C:Program FilesJavajre7libextQTJava.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

我花了好几天的时间试图独自解决这个问题。我已经把所有东西都重新安装了三次,就是看不出问题。在这件事上的任何帮助都将不胜感激。谢谢

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

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

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

相关内容

  • 没有找到相关文章

最新更新