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 jbmadsen · Sep 14, 2011 at 08:13 AM · dllopengldllnotfoundexception

DLLNotFoundException: C++ OpenGL code

Hi everyone.

I've created a small DLL to write to a texture directly from opengl without having to rely on the slow SetPixel/Apply functionality in Unity.

However, I'm having a problem of DLLNotFoundException.

Having searched around for a while, I've found multiple entries around this problem. However, looking at others working to get the same thing done, they have obviously done it ;)

The code I have is:

Header:

 #define EXPORT __declspec(dllexport)
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <windows.h>
 #include <gl/gl.h>
 
 extern "C"
 {
      extern EXPORT void updateTexture ( int texId, char* cvFeed, int w, int h );
 }

CPP file:

 #include "GLCalls.h"
 
 extern "C"
 {
     extern EXPORT void updateTexture ( int id, char* ptr, int width, int height )
     {
         glBindTexture( GL_TEXTURE_2D, id );
         glTexSubImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*) ptr );
     }
 }

Compiling goes just fine, and everything looks just dandy.. Until I enter and run in Unity, in which the code looks like this:

 [DllImport(DLL.GL_DLL.path, EntryPoint = "updateTexture")]
     internal static extern void UpdateTexture(int texId, IntPtr cvFeed, int w, int h);
 
 feed.updateTexture(texId, imgPtr, width, height);

Now.. I've created a couple of DLL's that is already running fine in Unity (other C++ and OpenCV stuff).. not a problem there.

Things I have tried:

  • Editor is already set to -force-opengl

  • I have gone through the DLL in dependency walker (can easily find the gl calls)

  • I've tried to add opengl.dll (and even re-coded the dll using glut and glew, and tried adding glut32.dll and glew32.dll) to the editor folder.

  • Removing the gl calls from the DLL and recompiling, in which case Unity can easily load it.

No luck. in getting gl calls to work.

I'm suspecting no static linking, and Unity (for some reason) not being able to load/find the opengl/glut32/glew32 dll files.

I'm working in Windows XP SP3, using Unity 3.4 Pro Trial, and Visual Studio 2008 Pro.

Anyone care to chip in.. I'm kinda clueless about how to fix this.

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 boat365 · Sep 14, 2011 at 08:53 AM

DLLNotFoundException, from what I read, means what it says: the DLL wasn't found (though it might be something else, I guess tackle the obvious thing first). Is the DLL in your Assets folder? And what is DLL.GL_DLL.Path? (In my experience, it just needs to be the base name of your DLL- so if your DLL is in 'Assets/plugin.dll', your DLLImport name should just be 'plugin').

I've built OpenGL DLLs on Windows before; all you need to link should be opengl32.dll.

Relatedly, you should use the __stdcall calling convention for your exported functions. That's what Mono expects on Windows.

Comment
Add comment · Show 4 · 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 boat365 · Sep 14, 2011 at 08:55 AM 0
Share

Oh- I see you say that if you remove the GL calls you can load the DLL. In which case I'm stumped: though I say again, this does work, and just by linking opengl32.dll.

avatar image boat365 · Sep 14, 2011 at 09:00 AM 0
Share

Actually, scratch that again: I'm not sure I've actually seen this work on Windows. It does work on $$anonymous$$acOS, such as what that's worth.

avatar image jbmadsen · Sep 15, 2011 at 12:41 PM 0
Share

Well, I will have to try it out on OSX one day then. I even tried building it to a standalone, hoping it was the editor not allowing me to get the dll, with no luck :(

avatar image boat365 · Sep 15, 2011 at 09:31 PM 0
Share

I've just realized; the editor won't let you -force-opengl anyway- that only works for standalones (according to the docs at least).

Anyway, I've put together a project that works on my system. I'm not sure how to post it on here though, so I've stuck it up on dropbox here: http://dl.dropbox.com/u/7654998/gltex.zip

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

use [DllImport("xxxx")] for .so with other .so 0 Answers

Using uEye Cameras in an Extension on a 64-bit machine 4 Answers

DLLNotFoundException - C++ plugin 1 Answer

Nvidia Ansel integration Issue :: DllNotFoundException 1 Answer

DLLNotFoundException 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