The static library is referenced in the process of Jni generating the dynamic library

Recently, there is a requirement. In order to prevent our game from being packaged twice, we need to check the MD5 value of the signature in the .so file. It is better to make a .a file for checking the signature and use it for the .so file of the game. .

So I started trying to generate a .a file for the game's .so file to use.

-------------------------------------------------

Some related instructions:

View the .a files that contain those files

    ar -t  xxx.a

View .so file interface

    nm -D xxx.so

Interface to view a (.a .o .so) file

    nm -C foo.a

    nm -C foo.o

(Add the -C command to output the original function declaration, refer to the post: http://blog.csdn.net/a_tu_/article/details/43987865 )

-------------------------------------------------

first day:

I tossed a bit to develop pure C++ under eclipse, very good, and also generated static library files, good~

 

the next day:

1. I wrote the Android.mk file according to the method mentioned on the Internet

Reference post: http://www.cnblogs.com/codingking/p/3852857.html

 

2. Enter the directory where jni is located and run the command ndk-build

 

3. Attempt to reference the static library in the game's .so file, but keep reporting an error when generating the .so file


According to the fourth case, it keeps reporting an error, why? According to the third situation, everything is ok, but the fourth situation will not work.

Later, I remembered that my .a file was generated by the C++ project, not according to the logic of Android, so I replaced it with the .a file generated in Case 3, and everything was ok!

 

4. Later, I tried to put all the c++ code in the static library, and an error was reported when running



Later, I checked the dynamic library file with nm -D *.so on Linux, and the cpp file compiled in the static library could not find the relevant symbols in the so file.



Later, I found that JNI methods are defined in the static library, for example: JNIEXPORT jstring JNICALL Java_***  

java will fail to call

但是,只是定义一些普通的C++方法,给C++代码调用,就一切正常。

 

一直没有解决~

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326333449&siteId=291194637