Use dll files in android Application

后端 未结 4 961
一生所求
一生所求 2020-11-29 12:22

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

相关标签:
4条回答
  • 2020-11-29 12:48

    Android runs on a Linux system - DLL files are usually bytecode compiled for Windows.

    0 讨论(0)
  • 2020-11-29 12:56

    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.

    0 讨论(0)
  • 2020-11-29 12:57

    You can use Wine on Linux to run programs that have dll-s. Also .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.

    0 讨论(0)
  • 2020-11-29 12:58

    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.

    0 讨论(0)
提交回复
热议问题