4

I am currently working on a Unity3d 4.0 Pro project where i am trying to link the tngaming vest to unity. The only SDK ( http://tngames.com/pages/Developers ) i have available is a C++ .h and a .lib file. As far as i understand from the documentation ( http://docs.unity3d.com/Documentation/Manual/Plugins.html ), i should simply put the two tngaming.h and tngaming.lib into my assets folder and do the following code:

[DllImport("tngaming")]
private static extern int SetUpJacket();

And that would allow me to call the function SetUpJacket(). However i get the DllNotFoundException: tngaming error.

Anyone who got some information doing something similar who can help out?

afuzzyllama
  • 6,538
  • 5
  • 47
  • 64
user1955256
  • 61
  • 1
  • 1
  • 4
  • 1
    Is the `tngaming.dll` in your Unity project's `Assets/Plugins` folder? When you run the .exe, is the DLL in the same directory as the .exe? – Chris Sinclair Jan 07 '13 at 14:39
  • As far as i know, there is no dll, just a .h and a .lib file. Secondly initially I'm just trying to get it to work and as such i am not exporting my unity to any exe file at this point. It is not working in the unity work window. – user1955256 Jan 07 '13 at 17:40
  • I'm not positive, but I think you _must_ use a compiled .dll. – Chris Sinclair Jan 07 '13 at 18:21
  • @ChrisSinclair That's [correct](http://docs.unity3d.com/Documentation/Manual/PluginsForDesktop.html). Also [relevant](http://stackoverflow.com/questions/729562/how-to-compile-c-sharp-application-with-c-static-library). – Jerdak Jan 07 '13 at 20:03

2 Answers2

2

Thank you all for your assistance.. The actual goal was to find a way to change unmanaged c++ code (.h and .lib file) to a unmanaged .dll and then create a c# wrapper..

It took a lot of very obscure searching but i managed to find a page that did exactly what i needed in a guide form.

http://waterhobo.com/?p=28

At the bottom of the page, there is a link in the line "Here is the source code i made" for those who want to skip the programming parts and just use the TN Gaming Vest in C#.

user1955256
  • 61
  • 1
  • 1
  • 4
0

From http://docs.unity3d.com/Documentation/Manual/PluginsForDesktop.html

Once built, the bundle should be placed in the Assets->Plugins folder in the Unity project. Unity will then find it by name.

MacOS libraries are .lib, Windows libraries are .dll, and Linux libraries are .so. The other commenters are incorrect; plugins do not have to be in .dll format. I believe (not sure) that .dll's will work on Mac as well.

cjcurrie
  • 624
  • 1
  • 4
  • 15