jni Pre-made So Dynamic Library Application

Asked 2 years ago, Updated 2 years ago, 108 views

Hi, how are you?

Developers who are dedicated to developing fire nights are working hard.

I've been doing it for a week, but I couldn't, so I posted a question.

First of all, the following error occurs.

I think the important point of the error log above is the contents below.

dlopen("data/app-lib/com.example.projecttest/libtest_print.so") failed: dlopen failed: could not load library "libgcc_s.so.1" needed by "libtest_print.so"; caused by library :libgcc_s.so.1" not found

java.lang.unsatisfiedLinkError : dlopen failed: could not load library "libgcc_s.so.1" needed by "libtest_print.so"; caused by library :libgcc_s.so.1" not found

It seems that libtest_print.so does not have the required libgcc_s.so.1 library...

I'm trying to solve this problem, but it doesn't work.

I will explain what I have done to ask for help from those who have experienced it before me.

===============================================================

Development tools are being developed using Eclipse.

ndk-build is on Windows.

The name of the project is com.example.projecttest.

It has the following source structure, and there are various .c files and Android.mk files in the jni folder, and what you want to do now is in test.c. The libtest_print.so file is a pre-created so dynamic library in Linux OS and created and added to the jni/lib folder.

In the jni/lib folder, the header file print.h is defined for writing functions created in the libtest_print.so file.

This was the description of the jni folder structure.

Let me explain the Android.mk file.

The Android.mk file in the jni folder.

I wrote down the module name to be PREBUILT with LOCAL_SHARED_LIBRARIES

LOCAL_LDLIBS said -L$(LOCAL_PATH)/lib/ -ltest_print. I added it because the ndk-build didn't work because they didn't do it.

Below is the file jni/lib/Android.mk.

Pre-created libtest_print.so file was used through PREBUILT_SHARED_LIBRARY.

The declared function of print.h can be used through LOCAL_EXPORT_C_INCLUDES.

After making it like this, ndk-build builds without errors, and the libGlobal_Jni.so file is created in the libs folder in armeabi-v7a.

And when I run the application, I loaded the main activity as follows.

If you do this and run the program, the error I mentioned for the first time will occur..

===============================================================

Before creating the jni/lib folder, there is a problem because it is a well-used jni and I want to use an externally made so file....

I would appreciate it if you could reply if there was anything I did wrong, or if there was any other solution or solution.

This is a question about additional content, but it is a little different from the above.

On Linux, when you compile the elf file (see dynamic library) using the toolchain (arm-linux-gnueabi) that uses the Android target board, and then use the adb push to put the executable file into the target board and run the file, the phrase no such file or directory occurs

I wonder if the elf file created by Linux can be applied to Android...

I couldn't do this, so I used jni...

jni ndk linux android

2022-09-22 19:21

1 Answers

Android is also Linux-based.

elf is a file format.

Windows binaries use peformat and Linux uses the elf format to create binaries.

There is a high probability that the So file made on Linux will be transferred to the Android device and checked for dependency, and if there is no problem, it will be fine.

First of all, to use the native library well using jni, a systematic understanding is required.

So files by Linux stand for shared objects and are shared libraries for the same purpose as dll in Windows.

These libraries also refer to other libraries internally, so all libraries you are referring to must exist for proper use.

First, please check the library you want to use as ldd on the equipment with Android installed.

How to use ldd.

https://www.joinc.co.kr/w/man/1/ldd

Oh, and I'm writing this down because I'm an old woman.Android usually uses an arm processor. The so file, which is said to have been made externally, is also compiled on arm-based Linux, right?


2022-09-22 19:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.