【问题标题】:Android NDK Samples Compilation error: string.h: No such file or directory [closed]Android NDK 示例编译错误:string.h:没有这样的文件或目录 [关闭]
【发布时间】:2012-01-28 03:00:00
【问题描述】:

我正在尝试编译 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 没有可用的 LSB 模块。 经销商编号:Ubuntu 说明:Ubuntu 11.10 发布:11.10 代号:oneiric 爪哇 $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ java -version java版本“1.6.0_22” Java(TM) SE 运行时环境 (build 1.6.0_22-b04) Java HotSpot(TM) 服务器虚拟机(内部版本 17.1-b03,混合模式) 制作 $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ make -v GNU Make 3.81 版权所有 (C) 2006 Free Software Foundation, Inc. 这是免费软件;查看复制条件的来源。 没有保修;甚至不适合适销性或适合性 特殊用途。 这个程序为 i686-pc-linux-gnu 构建 AWK $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ awk -W 版本 mawk 1996 年 11 月 1.3.3 日,版权所有 (C) Michael D. Brennan 编译限制: 最大 NF 32767 sprintf 缓冲区 1020 安卓 $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ 导出 | grep 安卓 声明 -x ANDROID_HOME="/media/rober/android/android-sdk-linux_86" 声明 -x ANDROID_NDK="/media/rober/android/android-ndk-r6b/" 声明 -x ANDROID_NDK_ROOT="/media/rober/android/android-ndk-r6b/" 声明 -x ANDROID_SDK_HOME="/media/rober/android/android-sdk-linux_86" PATH(以“\n”分隔,方便阅读) $:/media/rober/android/android-ndk-r6b/samples/hello-jni$ 导出 | grep 路径 | grep 垃圾箱 声明 -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: /斌: /usr/游戏: /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 目录结构中,但我不确定发生了什么。

非常欢迎各种提示:)

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      试试

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

      sudo find / -name string.h
      

      如果第一个不起作用

      【讨论】:

      • 头文件存在于NDK目录中,但由于某种原因找不到
        $ find /media/rober/android/ -name string.h /media/rober/android /android-ndk-r6b/sources/cxx-stl/stlport/stlport/string.h /media/rober/android/android-ndk-r6b/platforms/android-9/arch-x86/usr/include/asm/string .h /media/rober/android/android-ndk-r6b/platforms/android-3/arch-x86/usr/include/string.h /media/rober/android/android-ndk-r6b/platforms/android-3 /arch-x86/usr/include/linux/string.h
      • 其实文件名是string而不是string.h 你会在类似android-ndk-r8/sources/cxx-stl/gnu-libstdc++/include/string的地方找到它
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-05
      • 1970-01-01
      • 2014-06-04
      • 2015-10-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多