android中 JIN编译报错

编译报错: fatal error: string: No such file or directory

在开发一个测试用例时,需要用到一个JIN去调用底层借口,JIN文件为:otp_rw.cpp,然后相关makefile如下:

include $(CLEAR_VARS)# This is the target being built.LOCAL_MODULE:= libnative-libLOCAL_MODULE_TAGS := optional# All of the source files that we will compile.LOCAL_SRC_FILES:= \  native-lib.cpp\# All of the shard libraries we link against.LOCAL_SHARED_LIBRARIES := liblog# Also need the JNI headers.LOCAL_C_INCLUDES += \ $(JNI_H_INCLUDE)include $(BUILD_SHARED_LIBRARY)

编译时,出现错误。

  1. fatal error: string: No such file or directory
target thumb C++: libOTP_rw_test <= development/apps/project/jni/otp_rw.cppdevelopment/apps/project/jni/otp_rw.cpp:14:18: fatal error: string: No such file or directory #include                   ^compilation terminated.build/core/binary.mk:620: recipe for target 'out/target/product/morpho/obj/SHARED_LIBRARIES/libOTP_rw_test_intermediates/otp_rw.o' failedmake: *** [out/target/product/morpho/obj/SHARED_LIBRARIES/libOTP_rw_test_intermediates/otp_rw.o] Error 1make: Leaving directory '/home/administrator/projects/morpho_iris'

从log上来看是不能识别string,推测是缺少相应的依赖。
2. error: cast to ‘unsigned char *’ from smaller integer type ‘int’

development/apps/project/jni/otp_rw.cpp:356:25: error: cast to 'unsigned char *' from smaller integer type 'int' [-Werror,-Wint-to-pointer-cast]    uint8_t *database = (uint8_t *)GetBuffer(&size);

从log上来看是将int型转换成unsigned char *指针类型,而int太小了。后面将int强制转换成long后再cast to 'unsigned char *好像可以解决这个问题。

最后通过添加STL支持,问题一 和问题二 都可以解决具体修改如下:

include $(CLEAR_VARS)# This is the target being built.LOCAL_MODULE:= libnative-libLOCAL_MODULE_TAGS := optionalLOCAL_LDFLAGS += -ldlLOCAL_C_INCLUDES += \    bionic \    bionic/libstdc++/include \    external/stlport/stlport# All of the source files that we will compile.LOCAL_SRC_FILES:= \  native-lib.cpp\# All of the shard libraries we link against.LOCAL_SHARED_LIBRARIES := liblogAPP_STL := stlport_static# Also need the JNI headers.LOCAL_C_INCLUDES += \ $(JNI_H_INCLUDE)include $(BUILD_SHARED_LIBRARY)

更多相关文章

  1. mybatisplus的坑 insert标签insert into select无参数问题的解决
  2. Android(安卓)Studio 使用中遇到的问题和解决方案
  3. Android(安卓)Sdk Manager更新
  4. ndk 编译android内核模块无法加载 解决方法
  5. Android(安卓)编译手册
  6. [Android开发常见问题-21] Android(安卓)近百个项目的源代码
  7. Android——eclipse共享library以及导出jar包
  8. Android(安卓)常见知识整理(1)
  9. Ubuntu 14.10+NDK+ffmpeg编译+Android

随机推荐

  1. css
  2. 做好自定义预测,探寻产品增长动能
  3. postgresql vacuum 浅谈
  4. 建议收藏备查!MySQL 常见错误代码说明
  5. Github 星标 8K+ 这款国人开源的 Redis
  6. 苹果mac上超赞的AI照片编辑器:Luminar AI
  7. 2021年国内外五大BI厂商_商业智能工具推
  8. 小白专属mysql入门
  9. 手机内存不足应该怎么解决
  10. 最近做大数据面试官的感想