Re: c# to dll and dll to so... how to include so or dll into android java proejct?

2,102 views
Skip to first unread message

RichardC

unread,
Jul 31, 2012, 4:58:31 PM7/31/12
to andro...@googlegroups.com
Either
  • Re-write all the C# in C/C++ (and changing all the Windows specific calls) and build as an NDK library, or
  • Investigate if Mono for Android  http://xamarin.com/monoforandroid will help. You will still need to fix Windows only API calls.

On Tuesday, July 31, 2012 9:00:01 PM UTC+1, Károly Holczhauser wrote:

I have a huge problem, and I don't get understand it, so please help if you can.

We have a microcontroller library written in C# which has been converted out into a DLL file. It is okay, and nice. I have to write an Android "remote controller" application for the microcontroller, so I have to include the DLL into my Eclipse project, to be able call functions in it. It is not possible (I was not able to do :) ) so I'm trying to convert the DLL using the android NDK, because it is product and .so file.

My first question is, is this the right way?

After I have an so file, I woud like to include into my Eclipse project, but I was not able to do it. :(

Does anyone have any idea what I should do?

Thank you so much,

Doug Linder

unread,
Jul 31, 2012, 9:46:04 PM7/31/12
to andro...@googlegroups.com
Unfortunately, I suspect what you're trying to do simply isn't possible. 

You should probably have a read of this:

Basically, your DLL contains CLR byte code. There is no way to run that on an arm device without a CLR (ie. mono, since that's the only runtime that works on android). 

If your code was in C++ and you had a C++ DLL (which is different from a C# DLL, despite the same name) you would probably have an intermediate .lib file, which is more or less (as I understand it) the same as a .a from the unix world; ie. an archive of all your object code. 

Conceivably you might be build it targeting arm, and extract that archive, and then use some magic to convert the symbols in the object code from magical VS format to GCC compatible binary format. ...or you know, compile it using the toolchain directly.

...but a DLL? It doesn't matter what sort it is, it's a totally different thing to a .so file.

~
Doug.

On Wednesday, August 1, 2012 5:26:21 AM UTC+8, Károly Holczhauser wrote:
Hello ! 
 Thanks for your reply ! 
 The C/C++ way is not okay, and yes as you said and pointed so right we are trying to investigate for mono droid ! 
but I hope somehow I can covert dll into so or i can link dll into eclipse

cheers,
Karoly

Zoran Angelov

unread,
Jul 31, 2012, 10:46:18 PM7/31/12
to andro...@googlegroups.com
Maybe it is possible with using mono and llvm.
I think that Unity3D is doing something similar on iOS (maybe Android too).
Unity3D framework, Core framework and user scripts are actually generated as static library (.a), i guess with llvm.

If you have access to the DLL source code, you can try playing with following tools:



--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/-2paRlU08hoJ.

To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.

Reply all
Reply to author
Forward
0 new messages