Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by joelolofsson · Sep 01, 2015 at 07:26 AM · native plugin64-bitdllnotfoundexception

Cant run 64-bit dlls (native plugin)

Hi all! I have a dll created for 64-bit CPUs but i am unable to import them in unity. I have used the native plugin example as reference but built my own plugin. To verify the functionality of the plugin i have written a C# application that is able to call the plugins external functions, but when i use them in unity i get: DllNotFoundException

I am running x64 version of the unity editor. Has anyone succesfully used dll files for 64-bit cpus?

cheers

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Sep 01, 2015 at 09:49 AM

Are you sure you read this page carefully?

To sum up the most important points:

  • make sure your plugin exports it's method in an extern "C" { } block

  • Place your DLL file inside "/Assets/Plugins/"

  • If you build a x86_64 plugin make sure you have selected 64 bit build in the build settings

  • If you want to build both 32 and 64 bit builds you have to compile two seperate versions of your plugin and place them in the appropriate sub folder of the plugins folder ( "/x86/" and "/x86_64/" )

  • Finally, just in case it's not obvious: You can't use native code plugins in webplayer or WebGL builds for security reasons.

edit
I just created a simple "plugin" like this in C++:

 extern "C"
 {
     int __declspec(dllexport) DoSomething(int a, int b)
     {
         return a * b ;
     }
 }

And use it in Unity like this:

 [DllImport("UnityTestPlugin")]
 private static extern int DoSomething(int a, int b);
 
 void Start ()
 {
     Debug.Log("Result : " + DoSomething(3, 5));
 }

And it prints "Result :15" just fine. Of course i set the target platform in VS to "x64" and in Unity i set the target platform to Windows Standalone 64 bit.

Also check the inspector when you select your dll in Unity. Now you can select for which platform and which architecture a DLL should be used. By default a DLL is used for all platforms and all architectures. However since it's a x64 DLL it makes no sense to use it in x86 builds.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Sep 01, 2015 at 11:16 AM 0
Share

If you need more help, you have to be more specific about your case. Plugins definitely work just fine.

avatar image joelolofsson · Sep 02, 2015 at 09:50 AM 0
Share

Thanks, read through similar questions asked here and i was missing som dlls used within the created dll file. I managed to get rid of this error but when i use the dll unity crashes...

I am using a dll file, it works fine calling the functions in a visual studio console application, but when i do the same thing in unity it crashes. Any ideas for this?

thanks @Bunny83

avatar image
0

Answer by jemonsuarez · Oct 06, 2016 at 06:57 AM

Hi, maybe this solution in AssetStore can fix that:

Make your own native dll

Best regards.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by mynameisjun · May 16, 2018 at 02:37 AM

in my case. i had the same error message. and problem was that when i change dll file in unity editor, i just delete prev one and drag and drop new dll IN EDITOR. and i found that when i delete in editor, unity automatically regenerate the dll which was just deleted. so if you got 32dll first and have deleted it in editor, nothing was being actually changed. So just go to real file location, and delete the dll in file. hope it helps anyone

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Loading Windows 10 DLL. "This operation is only valid in the context of an app container" 1 Answer

Why the Unity3D only can load 32-bit native plugin(.so) on android platform? 1 Answer

Linux build is putting libNative.so in wrong place 1 Answer

DllNotFound Exception on Editor but works on Standalone 0 Answers

DllNotFound when the plugin c++ dll links another c++ dll 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges