Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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
1
Question by StephanK · Jan 16, 2010 at 10:57 PM · plugindll

dll loading in editor on windows

I wrote a c++ plugin, that does some stuff with fmod. The plugin itself seems to work just fine, and I can use it in a Windows standalone build when i copy the fmodex.dll next to the executable. However if I run the game in the editor I always get a DllNotFoundException. My understanding of dll's on windows is, that windows will look up the dll in the system32 folder (XP), then in the application folder and the current working directory. So I printed out the current working directory, which - no surprise - is the projects root folder. However, copying the fmodex.dll to that folder doesn't get rid of the Exception.

I have another project where I did something very similar (only with another dll) and this works. So any ideas what could go wrong here?

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

4 Replies

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

Answer by StephanK · Jan 20, 2010 at 12:00 PM

I think I finally have a clue what's going on. Since Unity2.6 switched to use fmod as audio core (which is a great idea!) there is a "fmodex.dll" in the edior application directory. Since my plugin was probably built using a different version of the fmodex lib it seems to find the one in the app directory and tries to load that. But since they are different versions the loader is not satisfied and I get the DllNotFoundException. At least that's what I think is going on.

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 Brian-Kehrer · Jan 17, 2010 at 03:19 PM

At least on the Mac, you are supposed to create a folder titled 'Plugins' inside the project view (assets directory). All plugin DLLs are to reside within that folder.

Try the same thing on windows.

From Unity Manual on Plugins

and an excerpt:

Once you have built your bundle you have to copy it to Assets->Plugins folder. Unity will then find it by its name when you define a function like this:

[DllImport ("PluginName")]
private static extern float FooPluginFunction ();

Please note that PluginName should not include the extension of the filename. Be aware that whenever you change code in the Plugin you will have to recompile scripts in your project or else the plugin will not have the latest compiled code.

Comment
Add comment · Show 3 · 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 StephanK · Jan 17, 2010 at 04:12 PM 0
Share

I did that. The problem is not that it simply not finds the plugin dll, but rather it does find it and then tries to find the fmodex.dll it depends on. I've put the dll in the project root, assets and assets/plugins folder just to be sure, but it just doesn't find it. The strange thing is, that when I build the project and start it standalone it DOES find the fmodex.dll which is right next to the executable...

avatar image Brian-Kehrer · Jan 17, 2010 at 09:39 PM 0
Share

I understand now. Unfortunately I don't have an answer, I haven't tried interdependent plugins.

avatar image StephanK · Jan 18, 2010 at 12:44 PM 0
Share

Normally this works as long as the dependencies live in the projects root folder. I think my problem is a bit more obscure as fmodex.dll seems to somehow depend on the dreaded dwmapi.dll and I'm on XP. Only thing I really don't get is why it's working in a standalone build, as the dll search paths should be the same for both.

avatar image
0

Answer by JC · Feb 11, 2010 at 11:06 AM

I got the same problem here when trying to load FModEx.dll + FMod_Event.dll in the Editor (build works fine).

The conclusion I got was that unity editor's FModEx.dll (the one unity uses since 2.61) is causing "Dll Hell" as the editor process binds it's own dll, we can't load our version. FMod_Event.dll has a dependency on FModEx.dll but it does not reconize unity's version. The result is that you get a "DllNotFoundException" when FMod_Event tries to find FModEx.

The solution I found was renaming my version, not unity's, of FModEx.dll to FModE2.dll and changing every occurrence of that name inside both dlls, Ex and Event, with a HexEditor. Now everything works fine. :-D

When building for Mac you will probably have to make your wrapper point towards the regular Dylibs. Somehtin like this:

    public class VERSION
{
    public const int    number = 0x00042808;

#if MAC

    public const string dll    = "libfmodex.dylib";

#else

    public const string dll    = "fmode2.dll";

#endif

}

Comment
Add comment · Show 3 · 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 seventyfive · Apr 19, 2010 at 04:46 PM 1
Share

hm, this doesnt work for me. did you change it inside the according libfmod_event.dylib and libfmodex.dll as well?

avatar image JC · Apr 19, 2010 at 09:00 PM 0
Share

@marco: Well, that's a good question. I don't recall changing the the dylibs for the $$anonymous$$ac build but I'm sure I had to build another Wrapper pointing them ins$$anonymous$$d of the regular DLLs.

avatar image seventyfive · May 02, 2010 at 10:02 PM 0
Share

ah, that makes sense, I will try that.

avatar image
0

Answer by Graeme · Jun 10, 2010 at 05:13 PM

[Removed Answer]

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

1 Person is following this question.

avatar image

Related Questions

Cant link PLUGIN.DLL with PLUGIN-EDITOR.DLL 1 Answer

Unity plugins 0 Answers

How can I access frame data using C# from the NatNetML.dll 0 Answers

Win Store plugin causing internal compiler error 1 Answer

Referencing a DLL in C# 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