Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use dll files in android Application

Tags:

android

dll

Can I use dll files (commonly used in windows Application) in Android application?

like image 561
Hossein Moradinia Avatar asked Jan 25 '11 12:01

Hossein Moradinia


People also ask

Does Android use DLL files?

apk files that you have in Android (also a version of Linux) may have dll-s if you have a run-time inside that can run those dll-s. Unity and Xamarin both support dlls.

What is DLL file in Android?

A dynamic link library (DLL) is a collection of small programs that larger programs can load when needed to complete specific tasks. The small program, called a DLL file, contains instructions that help the larger program handle what may not be a core function of the original program.

What apps use DLL files?

The Microsoft Windows Visual Studio is a program that allows you to view, edit and build code into a DLL file.

How do I use a DLL file?

If you are using Windows 7 or newer, open the folder containing the new DLL file, hold the Shift key and right-click in the folder, and select "Open command window here". The Command Prompt will open directly to that folder. Type regsvr32 dllname . dll and press Enter.


2 Answers

If you have the src files for the DLL, try recompiling as an ELF32 shared object, then link that instead into your Android code (- below is a Windows solution):


set NDK_HOME=C:\Android\android-ndk-r9c   // customize this var for your own location   
set LD_LIBRARY_PATH=%NDK_HOME%\platforms\android-18\arch-arm\usr\lib
cd <C_SOURCE_DIRECTORY>

REM -- TEMPORARILY COPY SOME LIBS COMPILER MAY NEED  
copy %NDK_HOME%\platforms\android-18\arch-arm\usr\lib\crtbegin*.o .   
copy %NDK_HOME%\platforms\android-18\arch-arm\usr\lib\crtend*.o .

REM -- GENERATE YOUR OBJ FILE  
%NDK_HOME%\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\bin\arm-linux-androideabi-gcc.exe -g -I%NDK_HOME%\platforms\android-18\arch-arm\usr\include -c -fPIC YourLib.c -o YourLib.o

REM -- GENERATE SHARED OBJ FROM OBJ FILE  
%NDK_HOME%\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\bin\arm-linux-androideabi-gcc.exe -g -L%NDK_HOME%\platforms\android-18\arch-arm\usr\lib -shared -o YourLib_so.so YourLib_so.o

REM -- finally, remove the libraries previously copied to src directory

del .\crtbegin*.o     
del .\crtend*.o

You should now be able to use the resulting .so file in your Android project.

like image 75
Oke Uwechue Avatar answered Nov 14 '22 19:11

Oke Uwechue


DLL stands for "Dynamic Link Library" and is a Windows concept. The equivalent in linux is SO (Shared Object).

You can refer to this article in CodeProject for similarities and differences between the two.

This Stackoverflow question is pretty similar.

like image 40
Lior Avatar answered Nov 14 '22 18:11

Lior