Android--jni and C language common terms

Source: Internet
Author: User

Reprint Please specify source: http://blog.csdn.net/l1028386804/article/details/47450717

Library functions:

| -for code reuse , the C language provides some common use for performing some standard tasks ( such as input / output ) Functions , these functions are compiled beforehand , generate the target code , and then package the generated target code into a library file for reuse . functions in library files are called Library functions , and library files are called function libraries .

| -the intermediate code in the C Language library function in Windows is suffixed with. obj , which is suffixed with. o in Linux.

Tip: A single target code cannot be executed directly , and the target code needs to use the connector to concatenate the target code and other library functions together to generate the executable file before it runs. Files for the. dll under Windows, Linux. So. a file.

Header file:

|-  The header file is a declaration of functions , macros , types , global variables, etc. defined in a library , similar to a warehouse manifest . If you need to use a function from a library in a user program, you only need to include the header file for that library in your program.

   |- A function prototype for all functions in the library is defined in the header file . The specific implementation of the function is in the library file .

| -Simply put: The header file is for the compiler , and the library file is for the connector .

| -When the connector is connected to the program, the corresponding library function is imported into the program according to the header file imported from the user program . The header file is named suffix . h .

function library:

|- Dynamic Library : The library functions used within the user program are not connected to the target code of the user program when compiling the user program , only at run time , and the corresponding function in the library is called when the user program executes to the relevant function , so the executable file generated by The dynamic library is relatively small.

|- Static Libraries : When you compile a user program , the library functions that are used in it are connected to the target code , and the static library is no longer required when the program runs. using a static library to build the executable file is relatively large .

In Linux:

|-   Static library naming is generally:lib+ library name +. A .

| -such as:libcxy.a which Lib indicates that this file is a library file ,cxy is the name of the library. A description is static .

|- Dynamic library naming is generally: lib+ library name +. So. . So The description is dynamic .

Cross-compiling:

| -When connecting the intermediate code to a binary program that is executable by the current computer , the connector is based on the current computer's CPU, the type of the operating system to convert.

Depending on the device you are running, you can divide the CPU into:

| -arm structure: mainly in Mobile handheld , embedded devices .

| -x86 structure: Mainly used in desktops and notebooks . such as Intel and AMD's CPUs.

If you want to compile in an operating system that uses a x86 -based architecture CPU , you can use an arm - based architecture CPU Code that runs on the operating system , you must use cross-compilation .

Cross-compiling: compiles binary code that can be executed in another platform under one platform . The NDK proposed by Google can do cross-compilation work.

NDK Full Name: Native development Kit.

|-  The NDK is a collection of tools that have many effects .

| -First, the NDK can help developers quickly develop C(or C + +) dynamic libraries .

| -Second, the NDK integrates a cross compiler . Using the NDK, we can improve application execution efficiency by using C development for application logic that requires high performance .

The NDK tool must run under Linux, and it can compile binary library files that can be run under the ARM platform in a Linux environment.

The use of JNI technology, in fact, is in the Java program, called the C language function library provides functions to complete some of the Java language can not complete the task. Because the Java language and the C language structure are completely different, if you want to interact with them, you need to develop a series of specifications . JNI is this set of specifications, when Java interacts only with JNI, and the C language interacts with JNI.

JNI technology is divided into two parts:Java side and C language side . And is dominated by the Java side.

| -First, Java programmers define some native methods on the Java side and provide these methods in the form of a C - language header file to C programmer .

| -Then, C programmers use the C language to implement functions defined in the header files provided by the Java programmer .

| -Next, the C programmer Packages the function into a library file and gives the library file to the Java programmer .

| -Finally, the Java programmer Imports the library file into the Java Program and then calls the native method.

When the Java program executes, if the native method is called in a class , the virtual opportunity passes through JNI to invoke the C Language code in the library file. Tip: TheC code is ultimately executed in the Linux process, not in the virtual machine .

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android--jni and C language common terms

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.