x


Publish Unity app with .dll plugin

I am using the Unity Pro 2.6 version, and I am trying to incorporate an external dll into the software via:

[DllImport ("myDllName")] private static extern void myDllFunct();

So far I have got it to work on the development box both in the unity editor and a built Windows Standalone. However when I take the Windows Standalone to a different computer the dll functions do not work. In fact the dll functions seem to crash any function they are put in. The unity app runs fine, but it is not able to talk to the dll.

Here is an example of what is happening:

// txBoxData is a class string that is rendered in a GUI.TextField.

[DllImport ("myDllName")] private static extern void myDllFunct();

void Update(){ txBoxData = “debug1”; myDllFunct(); txBoxData += “debug2”; }

On the development box, the GUI.TextField shows “debug1debug2”, but on the test box the GUI.TextField shows “debug1_”.

Thanks for any help you can provide

more ▼

asked Jul 15 '11 at 08:49 PM

marcusq gravatar image

marcusq
1 2 2 4

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

Make sure that you don't have any missing dependencies for the DLL. In particular, if you built the DLL in Visual C++ in Release mode, you need the corresponding version of the Visual C++ runtime installed on the other computer. If you built it in Debug mode, you need the same version of Visual C++ itself installed.

more ▼

answered Jul 15 '11 at 08:52 PM

sneftel gravatar image

sneftel
1.7k 7 9 20

I built the dll in Visual C++ 2005. I switched it over to release mode and took out anything that says "debug" in the project settings. It is still not working. Are there any property settings I should change from the default win32 dll project. I am new to making dll's.

Jul 15 '11 at 09:23 PM marcusq
(comments are locked)
10|3000 characters needed characters left

May be a dumb question but did you put the DLL's on the different computer? Do they depend on other DLL's which might need to also be installed there? Are you sure they are in the correct folder?

more ▼

answered Jul 15 '11 at 08:52 PM

DaveA gravatar image

DaveA
26.4k 151 171 256

The new dll is in the AssetPlugins Folder for the editor and in the App_DataPlugins folder for the published. As I said It works as a stand alone on the dev box.

Jul 15 '11 at 09:18 PM marcusq
(comments are locked)
10|3000 characters needed characters left

I found the solution to this thanks to Ben 12’s suggestion. The default project settings for Visual Studio 2005 include the requirement for a msvcr80.dll file. Since the test box did not have that file the dll I created for the Unity build would not work (or give me the proper error message).

The way I fixed this was by changing the project setting C++->Code Generation->Runtime Library from “Multi-threaded DLL (/MD)” to Multi-threaded(/MT)” This significantly increased the size of the output dll, but I think it now lacks the dependency issues of the previous version.

more ▼

answered Jul 15 '11 at 09:54 PM

marcusq gravatar image

marcusq
1 2 2 4

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x230
x43

asked: Jul 15 '11 at 08:49 PM

Seen: 1071 times

Last Updated: Jul 15 '11 at 09:54 PM