1. Generate the. h header file, configure the. C file (see Android jni:android Studio using Gradle to compile A/C + + source code) 2. Writing android.mk
//android.mk Introduction Reference link: http://blog.sina.com.cn/s/blog_602f8770010148ce.html
Local_path:= $ (Call My-dir)The //android.mk file must first define the Local_path variable so that it can be used to find the source file in the development tree. The macro function ' My-dir ' is provided by the compilation system for returning the current path (that is, the directory containing android.mk)
Include $ (Clear_vars)//clear_vars is provided by the compilation system, specifying that the GNU makefile clears many local_xxx variables (such as Local_module, Local_src_files, local_static_libraries, etc. ...), except Local_path. Because all the compilation control files are in the same GNU make execution environment, all the variables are global, so it is necessary.
Local_module: =Juzijni//Represents the compiled dynamic library name. The name must be unique and does not contain any spaces and does not start with Lib
local_src_files:=Jni_use. C//indicates source code file
Include $ (build_shared_library)//= Compile build Shared library, is a compiler-supplied variable, pointing to a GNU makefile script that collects all the information defined in the LOCAL_XXX variable since the last call to ' include $ (clear_vars) ', and decides what to compile, How to do it correctly. (build_static_library: Compile as Static library; Build_shared_library: Compile as Dynamic library; build_executable: Compile as native C executable program)
build. So files using the Ndk-build command in a 3.linux environment
To specify a schema, you can use the following command:
ndk-build APP_ABI="armeabi armeabi-v7a x86 mips"
4. Use the generated. so fileUsing JNI under Android Studio:use. So files under Android studio"
Small tips:1.android.mk:2: * * * missing separator. Stop.
Local_path:= $ (call My-dir)
include$ (Clear_vars)
Local_module: = Juzijni
local_src_files:= jni_use.c
include$ (Build_shared_library)
WORKAROUND: The $ sign must precede a space
Local_path:= $ (call My-dir)
Include $ (clear_vars)
Local_module: = Juzijni
local_src_files:= jni_use.c
Include $ (build_shared_library)
2./home/emily/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/. /lib/gcc/arm-linux-androideabi/4.8/. /.. /.. /.. /arm-linux-androideabi/bin/ld:fatal error:./obj/local/armeabi/passworld:input/output ErrorCollect2:error:ld returned 1 exit status Workaround: This problem occurs when compiling the virtual machine and window's shared files, and copy the project to the Linux directory.
From for notes (Wiz)
Android jni:android Studio uses ANDROID.MK to compile the C + + source code