Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 noobler · May 16, 2015 at 03:50 AM · unity 5pluginunity 4.6nativedllnotfoundexception

Native plugin DllNotFoundExeption in Unity 4 (works in 5)

Hi,

I am trying to include a native C plugin for use in the Editor but cannot get it going in Unity 4 on Windows 8. I can compile it into a bundle and include it in the project in Unity 4 on Mac OS X. I can also compile it into a 64 bit shared dll and include it in Unity 5 on Windows. However, Unity 4 on Windows spits out a DllNotFoundException when I try to use either a 32 or 64 bit version of the shared dll.

I have tried placing the dll in: 'Assets/', 'Assets/Editor', 'Assets/Plugins', 'Assets/Plugins/Editor', and 'Assets/Plugins/x86', all to no avail (always spits out 'DllNotFounddException: PLUGIN_NAME', except when in the x86 folder, which produces: 'DllNotFounddException: FULL/PATH/TO/x86/PLUGIN_NAME').

Since the code is c99, I can't compile using VisualStudio. Instead, I'm using MinGW (tried on Linux, MacOSX and Windows) by running:

 i686-w64-mingw32-gcc -m32 -mwindows -c --std=c99 -DBUILDING_EXAMPLE_DLL *.c *.h
 i686-w64-mingw32-gcc -m32 -mwindows -shared -o myplugin.dll *.o

Has anybody encountered this before? Is there a reason that the plugin would work in Unity 5 but not Unity 4?

Thanks in advance..

//======================= EDIT - adding more info:

I'm using: Windows 8 64-bit

  • running in Bootcamp on a recent Macbook Pro 13

  • latest MinGW Unity

  • 4.6.5f1.

Also running the file command on the dlls in cygwin produces:

  • 32 bit: "PE32 executable (DLL) (console) Intel 80386, for MS Windows"

  • 64 bit: "PE32+ executable (DLL) (console) x86-64, for MS Windows"

so it seems to me that the produced dlls are compiled for the correct OS and architecture.

//======================= EDIT 2:

I've successfully compiled a test plugin (containing a function that adds two numbers) using the same commands as above and was surprised to see it works from Unity 4 when I DllImport the absolute file path (as opposed to just the dll name). Unfortunately, Unity still doesn't find the actual plugin I'm interested in even when using the absolute file path.

(Also, to preempt any such suggestions, switching the project to Unity 5 to get this going is not an option).

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by xcd · May 23, 2015 at 02:47 PM

I had this same problem using a 32-bit version of a dll on 32-bit Unity 5. I believe Unity 4 editor only supports 32-bit so this may be the same issue.

It looks like this is a misleading message and Unity can't find one of the dll's your dll has a dependency on. I finally got Unity to load mine by using the -static-libgcc flag to prevent mingw from linking with the shared version of the standard libraries.

However, I couldn't figure out how to get Unity to find/load the other dll so this may still be a problem for you if you have other dependencies and you can't link to them statically.

You can use http://www.dependencywalker.com/ to help figure out what your dll's dependencies are.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Scanning real time object. 0 Answers

Why does my 32-bit dll plugin(c++) work in Unity 4 and not in Unity 5 indy (Windows 32-bit editor) 0 Answers

using shared libraries generated by Android project in Unity 0 Answers

Android OpenGL error in Unity 5 but not in Unity 4.6 0 Answers

Why does deferred rendering flip the view and change the viewToWorldMatrix? 0 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