-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem when try to build a DLL for the API #31
Comments
Hi! I am having a similar problem. I had the same error trying to build a DLL for my Unity app.
I got the DLL to build and was able to call it through my C# program but the line: Is there a way to make an implicit call like suggested in the documentation. Thanks. |
I would not try to return research mode interfaces into unity. Just export entry points that call into the rm apis. Basically initialize open, close and getbuffer exports from your dll, Also if your Unity app is not arm64 the RM dll will not load. We are working on adding arm support. |
Hi @aal-rvr It seems that you are using windows runtime component template to build the project? My project template in VS2019 is DLL(Universal Windows). I just followed sample in the API Doc, so my code is extremely simple .
Hi @dorinung Best, |
@aal-rvr Dll and Unity build have to be ARM64. I am loading the the rm API with
And use similar code as @whirwind to init the sensors. |
@dakesse Thanks for your advice, I successfully get a resolution parameter from my DLL in Unity. Although more work need to do to get the raw sensor data, initial problem has been solved. Here is what I learn:
|
@whirwind did you manage to marshal the data buffer of |
@whirwind , I get the exact same error as you did in the beginning. How did you call the 'CreateResearchModeSensorDevice' function via LoadLibraryA("ResearchModeApi") ? I can't seem to get it working. Thanks 👍 |
@dakesse Exactly. I was working for this past few days. I return a Byte* pointer in C++ and receive it in C# using IntPtr, then use marshal.Copy. But today I found that app will have crashing problem. I guess it is because I did something stupid while passing the pointer and lead to some kinds of memory leak.
Do you have any advice about this? Thanks. @agroenenberg Sorry for the late reply. It is clear in the init() function in samples. It is some thing like this:
|
@whirwind On the C++ side I added a new struct because I had problems to access the array of the sensor values inside the respective struct array. So I just splitted them up into 3 single values.
My functions then return a pointer to such a struct array.
On the C# side I have the same struct with corresponding C# types that I just use inside a 'unsafe' block to get the data from my C++ DLL.
By declaring the imported function as 'unsafe' you can just use pointers as if you where working with C++.
To work with the retreived data everywhere else in Unity i copy them into another safe struct. |
Okay I've been trying to get this DLL working on the HoloLens 2 for days now and it's driving me to insanity. I tried every way I could find, the testfunction works perfectly on Unity but I keep getting this error on the HL2:
I did everything as described, built the DLL for x64 and ARM64, put them in the right folders in Unity(ARM64 for UWP and WSAplayer only), x64 for every platform except WSAplayer. Added DLL to project and set content to "Yes". I tried everything with each time a different component. (only ARM64, only x64, build via Unity, not adding to project). Everthing built and configured in Debug Mode. It should just give me (int a + int b) in the VS terminal after uploading to HL2. Please can anyone help me? @dakesse @whirwind How did you guys get it working on the HL2? |
Hi @dakesse , While trying to make the DLL work for a C++ UWP app, I am running into an error: Do you know what else needs to be changed? Thanks! |
I found the solution to my problem and maybe for yours too @aal-rvr . I installed Dependency Walker to check if my DLL was dependent on any other dlls that were not included. After some checks and research this is what solved it: When building the DLL itself, I changed C/C++> Code Generation> Runtime Library from MDd to MTd and now it works! Even if yours doesn't work, try https://www.dependencywalker.com/ to check your dll on dependencies. |
Hi @aal-rvr , |
Nice that you found a solution. |
Thanks for the advice. My setting is /MDd by default. My original DLL might have had some differences as it was created in VS2017 (although the properties match my new DLL exactly), After quickly making a UWP DLL in VS 2019 it works as expected for C++ UWP Blank App. For this I only added the .lib file and didn't have to add the DLL. |
Did anyone actually use a Windows Runtime Component instead of a DLL? I'm trying to record/ save 1 pointcloud from the AHAT sensor so I can process that on my desktop and send some data back to the HL2. I don't want/need any frames of the data on my Unity app, I just want to save a pcloud via my app that I can then access. |
@dakesse Hi there, thanks for your detailed instructions. |
Sorry, unfortunately not. I was only interested in the IMU data. |
Hello!
I want to get the access to the sensor data in Unity. Now what I am doing is trying to build a Universal Windows DLL file. And I got this error:
I am new in this field and I guess I might have made some basic mistakes about this project.
Best,
whirwind
The text was updated successfully, but these errors were encountered: