Android NDK示例编译错误:string.h:没有这样的文件或目录

时间:2011-12-26 18:41:57

标签: android android-ndk ubuntu-11.10 string.h

我正在尝试编译Android ndk示例android-ndk-r6b / samples / hello-jni,我没有运气。

我得到的编译错误是:

 $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ ndk-build
    Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
    Gdbsetup       : libs/armeabi/gdb.setup
    Compile thumb  : hello-jni &lt= hello-jni.c
    /media/rober/android/android-ndk-r6b/samples/hello-jni/jni/hello-jni.c:17:20: error: string.h: No such file or directory
    /media/rober/android/android-ndk-r6b/samples/hello-jni/jni/hello-jni.c:18:17: error: jni.h: No such file or directory
    /media/rober/android/android-ndk-r6b/samples/hello-jni/jni/hello-jni.c:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Java_com_example_hellojni_HelloJni_stringFromJNI'
    make: *** [/media/rober/android/android-ndk-r6b/samples/hello-jni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o] Error 1


环境:



     Ubuntu
        $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ lsb_release -a
        No LSB modules are available.
        Distributor ID: Ubuntu
        Description:    Ubuntu 11.10
        Release:    11.10
        Codename:   oneiric

        Java
        $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ java -version
        java version "1.6.0_22"
        Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
        Java HotSpot(TM) Server VM (build 17.1-b03, mixed mode)

        Make
        $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ make -v
        GNU Make 3.81
        Copyright (C) 2006  Free Software Foundation, Inc.
        This is free software; see the source for copying conditions.
        There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
        PARTICULAR PURPOSE.
        This program built for i686-pc-linux-gnu

        AWK
        $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ awk -W version
        mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan
        compiled limits:
        max NF             32767
        sprintf buffer      1020

        Android
        $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ export | grep ANDROID
        declare -x ANDROID_HOME="/media/rober/android/android-sdk-linux_86"
        declare -x ANDROID_NDK="/media/rober/android/android-ndk-r6b/"
        declare -x ANDROID_NDK_ROOT="/media/rober/android/android-ndk-r6b/"
        declare -x ANDROID_SDK_HOME="/media/rober/android/android-sdk-linux_86"

        PATH ( splitted by "\n" for easy reading )
        $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ export | grep PATH | grep bin
        declare -x PATH="
        /media/rober/dev/apache-ant-1.7.1/bin:
        /media/rober/dev/apache-maven-3.0.3/bin:
        /media/rober/android/android-sdk-linux_86/platform-tools:
        /media/rober/android/android-sdk-linux_86/tools:
        /media/rober/android/android-ndk-r6b/:
        /usr/lib/lightdm/lightdm:
        /usr/local/sbin:
        /usr/local/bin:
        /usr/sbin:
        /usr/bin:
        /sbin:
        /bin:
        /usr/games:
        /media/rober/dev/jdk1.6.0_22/bin:
        /media/rober/dev/apache-ant-1.7.1/bin:
        /media/rober/dev/apache-maven-3.0.3/bin:
        /media/rober/android/android-sdk-linux_86/platform-tools:
        /media/rober/android/android-sdk-linux_86/tools:
        /media/rober/android/android-ndk-r6b/

我觉得我错过了一个环境变量或某种配置,告诉ndk在哪里查找string.h和jni.h文件,即使它们在同一个ndk目录结构中,但我不确定会发生什么。

非常欢迎各种提示:)

2 个答案:

答案 0 :(得分:1)

编辑:我更新到r7,一切正常,很奇怪。

答案 1 :(得分:0)

尝试

find /media/rober/android/ -name string.h

sudo find / -name string.h

如果第一个不起作用