Li Che
Li Che

Reputation: 737

Android DNK developed so file. How to call it directly in Linux?

Now I have a so file which developed by DNK. I want to call the so file use C in Linux. But it always prompts:

[root@PCGiter Code]# gcc SoTest2.c -o SoTest2.exe -ldl
[root@PCGiter Code]# ./SoTest2.exe
Open Error:libcom_wuba_aes_ExecV3_1_0.so: cannot open shared object file: No such file or directory.

Upvotes: 0

Views: 293

Answers (1)

Suman
Suman

Reputation: 4251

This answer is for creating the executables for Android and executing them in shell like in Linux, but not how to execute Android executables in Linux.

Use Android-ndk for building the source files, then you can copy directly to emulator and execute in the adb shell.

Example of the make file for creating an executable for android

# For building the Test executable
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

# Linker flags
LOCAL_LDLIBS += -llog
LOCAL_LDLIBS += -lOpenSLES
LOCAL_LDLIBS += -landroid

# Include paths
LOCAL_C_INCLUDES := \
$(LOCAL_PATH) 

# Local C Flags if any
LOCAL_CFLAGS := 

# Source Files to compile
LOCAL_SRC_FILES := \

# Shared libraries to be used while linking
LOCAL_SHARED_LIBRARIES := 

# Local module name
LOCAL_MODULE := 

include $(BUILD_EXECUTABLE)

You can get in to the emulator shell by launching the emulator and then executing the command in command prompt "adb shell" .

Usually what I observed is when copied to /data/ folder only, I was able to execute. Other folders such as /mnt/sdcard I was not able to execute the executable.

Upvotes: 1

Related Questions