LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Linux : Unity3d DllImport (“filename”) not working (https://www.linuxquestions.org/questions/linux-software-2/linux-unity3d-dllimport-%93filename%94-not-working-4175579770/)

ashokbugude 05-14-2016 06:45 AM

Linux : Unity3d DllImport (“filename”) not working
 
I have imported "Kinect with OpenNI2"( https://www.assetstore.unity3d.com/en/#!/content/10693) from Unity Asset store. When I run the code , I get below error message
...................................................................
System.DllNotFoundException: UnityInterface2
at (wrapper managed-to-native) KinectWrapper:Init (bool,bool,bool) at KinectManager.Start () [0x00000] in /home/ashok/New Unity Project/Assets/KinectScripts/KinectManager.cs:657
UnityEngine.Debug:LogError(Object) KinectManager:Start() (at Assets/KinectScripts/KinectManager.cs:808)
..................................................................
The error message is generated when below code is executed

[DllImport("UnityInterface2", SetLastError=true)]
public static extern int Init(bool isInitDepthStream, bool isInitColorStream, bool isInitInfraredStream);

.......................................................................

I have found below things

[DllImport("UnityInterface2", SetLastError=true)] ------- not working
[DllImport("UnityInterface2.dll", SetLastError=true)] ------- not working
[DllImport("UnityInterface2.dylib", SetLastError=true)] ------- not working
[DllImport("UnityInterface2.so", SetLastError=true)] ------- working but do not want to use it ( unreferenced symbols as I am unable to compile the .cpp and .h files properly from https://github.com/rfilkov/OpenNi2UnityInterface to generate .so file)

..............................................................................

UnityInterface2.dll and UnityInterface2.dylib are proper compiled files, but unable to use

John VV 05-14-2016 11:17 PM

can you explain what you are doing

from what i see you are using apple osx "xcode" to run Microsoft software on linux
???
and that makes zero sense

ashokbugude 05-15-2016 12:37 AM

Aim : To do gesture recognition (hand tracking) on Linux

Hardware : Kinect xbox360

Softwares : Linux,OpenNI2, NiTE2

Unity Package used : Kinect with OpenNI2 (https://www.assetstore.unity3d.com/en/#!/content/10693)


Existing things about the package (code ):Its meant for windows OS and Osx (Apple)
(Package contains UnityInterface2.dll (Windows) and libUnityInterface2.dylib(OsX))
(Package does not contain UnityInterface2.so (Linux))

Existing Platform dependency code :
.....Platform Independent C# code (specifying location of OpenNI2/NiTE2 installation directories(OsX/Linux)..............

If(OS == WIndows OS )
use UnityInterface2.dll library [DllImport("UnityInterface2.dll")] ;

else if (OS == OsX )
use libUnityInterface2.dylib library; [DllImport("libUnityInterface2.dylib")] ;


......... Platform Independent C# code (calling functions in library ) ..............

Requirement : To modify the code to make it work with Linux in following ways

1. Use the existing library files (.dll and .dylib ) and call its functions, ie

If( OS == Linux ) use UnityInterface2.dll library; [DllImport("UnityInterface2.dll")]---- (NOT WORKING))

OR

If( OS == Linux ) use libUnityInterface2.dylib Library [DllImport("libUnityInterface2.dylib")](NOT WORKING))


2. Create a .so file (UnityInterface2.so) by compiling the .h and .cpp files in https://github.com/rfilkov/OpenNi2UnityInterface location and use the following code

If( OS == Linux ) use libUnityInterface2.so Library [DllImport("libUnityInterface2.so")]


Result : unreferenced symbols as I am unable to compile the .cpp and .h files properly


Basically Trying to use 1st option, ie to make Linux identify .dll or .dylib files)

John VV 05-15-2016 12:43 PM

unless you MUST USE this Microsoft owned C# code ( requiring MONO on linux to replace "Microsoft Dot Net Framework")
and getting Apples Xcode working on linux

i would look at using OpenCV
it already is linux code

and as far as i know opencv has been used with a MS kinetic for image registration tracking

ashokbugude 05-16-2016 08:14 AM

Hi ,

Can I know if I understood correctly ?

Do I need to replace the '4.5' folder at /usr/bin/mono/lib/ of Linux with '4.5' at C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\ of Windows ?
...................................................................................

I found one thing in Linux

Unity/C# is able to recognize independent .dll files ie
If dll A is not dependent on any other dlls it is recognized

Unity/C# is not able to recognize dependent .dll files ie
If dll A is not dependent on dll B,dll C,dll D etc then dll A is not recognized, although all the 4 dlls( A,B,C,D dlls ) are in same location


.................................................................................................... .....

I have used dependency Walker for UnityInterface2.dll and found out that it depends on OpenNI2.dll, NiTE2.dll, msvcp90d.dll and kernel32.dll. I have placed all of these in project folder of Unity and also in 4.5 folder , but the issue still persists.

Can I know how do I make C# code recognize a dll (UnityInterface2.dll) which depends on other dlls
(OpenNI2.dll, NiTE2.dll, msvcp90d.dll and kernel32.dll) in Linux ? Please help


All times are GMT -5. The time now is 06:22 PM.