Quantcast
Channel: Questions in topic: "dllimport"
Viewing all articles
Browse latest Browse all 160

Editor on Windows 10 crashes when using a native dll; Build works, though

$
0
0
Hello everybody, I want to use a native C library (x64 DLL) in my project. I use Unity 5.6 (had the same issue with 5.5, just updated it) on a Windows 10 machine. Everytime I try to execute a function from this DLL the editor crashes. If a make standalone build, however, it works most of the time. Most of the time means, that it can be necessary to start the .exe several times until it doesn't crash. I made the DLL myself using cygwin 64 and it doesn't use any other library. The same code works on mac btw. Here is the code (it's extremely basic and still doesn't work) **testc.h** #ifndef TEST_H #define TEST_H extern "C" { int muliply (int a, int b); } #endif / TEST_H / **testc.cpp** #include "test.h" extern "C" { int mulitply(int a, int b) { return a*b; } } **testscript.cs** using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using UnityEngine; public class testcscript : MonoBehaviour { [SerializeField] TextMesh textField; [DllImport ("CppDynamicLibrary")] private static extern int mulitply (int a, int b); // Use this for initialization void Start () { textField.text = "Result: " + mulitply (6, 7); } } The dll's name is "CppDynamicLibrary.dll" and is located in the "Assets/Plugins/x86_64" folder. In the editor logs I find this Line: Failed to load 'Assets/Plugins/x86_64/CppDynamicLibrary.dll' with error 'A dynamic link library (DLL) initialization routine failed.' I would love to know, what I could do differently or if this a bug with Unity on Windows 10. Best Regards, Andreas

Viewing all articles
Browse latest Browse all 160

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>