zoukankan      html  css  js  c++  java
  • android NDK 生成so 文件流程-ecplice

    1:生成jni目录

    首先说一句网上,大部分博客这么写的:打开控制台,进入项目目录,运行
    javah -classpath bin/classes -d jni com.example.hellojni.MainAcitivity

    我只想问一句,这些代码您亲自运行成功了吗?您这么写出来责任心何在?

    这么写你会遇到这个错误。

    实际上可以这么写:

    1: javah -classpath src -d jni com.itg.jni.ImageBlur

    或写入android.jar的路径直接执行

    2:javah -classpath C:projectAndroidadt-bundle-windows-x86_64-20131030sdkplatformsandroid-22android.jar;bin/classes -d jni com.itg.jni.ImageBlur

    然后你会在项目中得到jni文件夹及.h的文件

    然后编写C文件。

    3:右键jni文件 添加Android.mk文件

    写入配置

    LOCAL_PATH := $(call my-dir)
    include $(CLEAR_VARS)
    LOCAL_MODULE   := JNI_ImageBlur
    LOCAL_SRC_FILES := com_itg_jni_ImageBlur.cpp
    LOCAL_LDLIBS    := -ljnigraphics -llog
    include $(BUILD_SHARED_LIBRARY)
    LOCAL_LDLIBS    := -ljnigraphics -llog 这一句如果没用到BitMap不要添加。
    我的需求是,操作图片 如果没有这句汇报

    在编译jni的cpp文件时出现:

    jni/NDKtest.cpp:21: error: undefined reference to 'AndroidBitmap_getInfo'
    jni/NDKtest.cpp:22: error: undefined reference to '__android_log_print'
    jni/NDKtest.cpp:26: error: undefined reference to '__android_log_print'
    jni/NDKtest.cpp:29: error: undefined reference to 'AndroidBitmap_lockPixels'
    jni/NDKtest.cpp:30: error: undefined reference to '__android_log_print'
    jni/NDKtest.cpp:39: error: undefined reference to 'AndroidBitmap_unlockPixels'
    collect2.exe: error: ld returned 1 exit status
    make.exe: *** [obj/local/armeabi/libNDKtest.so] Error 1
     

    2 下载NDK(Native Development Kit)

    2:选中要生成so 文件的项目选择Property-->Builders-->New

    设置Location,添加 ndk-build.cmd

    设置working Directory 选择项目中jni目录 

    设置build Options

    勾选如图所示

    设置Specify Resources,直接选择jni文件夹即可。完毕,保存,ecplice会自动在armeabi文件夹下生成so文件

  • 相关阅读:
    验证码生成程序
    会话技术Cookie&Session
    jsp基础、el技术、jstl标签、javaEE的开发模式
    js原生的Ajax
    java基础-反射
    hibernate 联合主键 composite-id
    在ubuntu18 安装nginx过程,以及遇到的错误!
    报错解决:error: this statement may fall through [-Werror=implicit-fallthrough=]
    nginx.conf中关于nginx-rtmp-module配置指令详解
    搭建Nginx+nginx-rtmp-module的hls流媒体服务器并用OBS进行推流
  • 原文地址:https://www.cnblogs.com/newsouls/p/4815973.html
Copyright © 2011-2022 走看看