microsoft / Quantum

Microsoft Quantum Development Kit Samples
https://docs.microsoft.com/quantum
MIT License
3.88k stars 919 forks source link

Building for 3rd party application #336

Closed kobaltic closed 3 years ago

kobaltic commented 4 years ago

I apologize as this isn't the correct area for this question. I can't find a forum, subreddit or discord channel for QDK. If there is one please let me know.

I decided to create an API for video game engines. I am starting with Unity (as it is C#) and then moving to UE4.

I have built a release version of the QDK in VS2017 and have the complied dlls. I added the dlls to my project and I added the necessary scripts to make it work.

I have it working in the editor and in a stand alone build on my pc. The issue I have is that when I tested my build on my wife's pc it does not work. I get an error 'plugins failed to load. One or more dependencies could not be loaded' The error is from the simulators dll and this is the line it errors on using (var sim = new QuantumSimulator())

I feel like I am missing a file or something that I should include in my build but I can't figure it out. I assume that the simulator is in the dlls and isn't a separate application. Here is a screenshot of my setup in Unity. image

anpaz commented 4 years ago

hi @kobaltic, Sorry for the late response! The simulator is built for the x64 platform and will fail to load if on Any or 32 bits applications. Could this be the problem? Any other information in the logs? Curious, what are you planning to use the simulator for?

kobaltic commented 4 years ago

@anpaz-msft No problem. Yes I built it for 64 bit. I have the whole log here http://kobaltic.com/QDK/Player.log My plan is to be able to code server side functions for video games through an easy to use API. My hope is that the code will transition seamlessly from the simulator to an actual quantum computer. One of the first things I am looking into doing is develop AI for highly complex games.

kobaltic commented 4 years ago

I did some experimenting a tried this on 4 computers. It worked on 3 computers. The 3 that it worked on all had VS2017 installed. The one it did not work on did not have and VS installed. I wonder if it needs a file from VS or a redistributable installed.

guenp commented 3 years ago

Tagging @erikkre @vxfield ; perhaps one of you could help answer this question?

kobaltic commented 3 years ago

I have some updates. I took the dlls that come with 2019 redistributables and added them to my project. That worked and now it works on every windows computer I tested it on. I have heard that you are not allowed to package these dlls in your own project.

The next issue is that when I build it for Android, WebGl or IOS, it doesn't work. I suspect those dlls are making calls to other dlls on the windows computers.

After all this it seems I will have to abandon this project and use a quantum package that doesn't need Windows to work.

vxfield commented 3 years ago

QDK is built using .NET Core and it’s cross-platform, so there is not specific Windows dependency in it. However, when building for Android, WebGL or iOS I guess you will need something like Mono to run .NET code in those platforms and then you might hit some issues running QDK over the Mono runtime as we don’t explicitly support that scenario (although it could be technically possible for you to try, I think). But the main problem that you will probably face will be with the native simulators, which are built specifically for Windows, Linux or MacOS. You would have to try to use (and port) the native simulator C++ code to be compiled for those platforms, and then you might hit some other issues (specially performance issues).

Anyway, I wouldn’t try to use the QDK components/API directly on a client side of a game engine. It would be better for you to create your own server-side component that runs on Windows/Linux/MacOS and calls QDK. And then, the game engine client would call your server to pass things to be run on it, or to further be offloaded to a real quantum computer using Azure Quantum.

From: kobaltic notifications@github.com Date: Monday, December 21, 2020 at 10:52 AM To: microsoft/Quantum Quantum@noreply.github.com Cc: XField vxfield@outlook.com, Mention mention@noreply.github.com Subject: Re: [microsoft/Quantum] Building for 3rd party application (#336)

I have some updates. I took the dlls that come with 2019 redistributables and added them to my project. That worked and now it works on every windows computer I tested it on. I have heard that you are not allowed to package these dlls in your own project.

The next issue is that when I build it for Android, WebGl or IOS, it doesn't work. I suspect those dlls are making calls to other dlls on the windows computers.

After all this it seems I will have to abandon this project and use a quantum package that doesn't need Windows to work.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FQuantum%2Fissues%2F336%23issuecomment-749135662&data=04%7C01%7C%7Cfbabb33719484c2e758d08d8a5e1993d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637441735643966462%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=e8uIajo0BJmy%2BzChKq47MNTN9FKnkkyXMRkDin2a1Hw%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAN3JLUL7AXT2JV3X4JJ6DT3SV6KPVANCNFSM4MKYP5HQ&data=04%7C01%7C%7Cfbabb33719484c2e758d08d8a5e1993d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637441735643966462%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=TIidEStIw%2FT2ZOVohjTABP%2BTfGU%2F2NV0IjutEf%2F%2B8qw%3D&reserved=0.

kobaltic commented 3 years ago

@vxfield Thank you. You are correct. I should keep QDK on the server. That should also make it easier to switch to an actual quantum computer. That would also solve my issues and allow me to build for other platforms.

I had planned on using a server down the road. I was trying to keep things as simple as possible while I was learning QDK. Thanks again.