author | description | ms.author | ms.date | ms.service | ms.subservice | ms.topic | no-loc | title | uid | ||
---|---|---|---|---|---|---|---|---|---|---|---|
bradben |
Learn how to develop Q# applications in an editor/IDE and run applications from the .NET console |
v-benbra |
02/01/2021 |
azure-quantum |
qdk |
quickstart |
|
Develop with Q# applications in an IDE |
microsoft.quantum.install-qdk.overview.standalone |
Learn how to develop Q# applications in Visual Studio Code (VS Code), Visual Studio, or with any editor/IDE and run applications from the .NET console. Q# programs can run on their own, without a driver in a host language like C#, F#, or Python.
While you can build Q# applications in any IDE, we recommend using Visual Studio Code (VS Code) or Visual Studio IDE for developing your Q# applications locally. Developing in these environments leverages the rich functionality of the Quantum Development Kit (QDK) extension, which includes warnings, syntax highlighting, project templates, and more.
Important
If you are working on Linux, you may encounter a missing dependency depending on your particular distribution and installation method (e.g. certain Docker images). Please make sure that the libgomp
library is installed on your system, as the GNU OpenMP support library is required by the quantum simulator of the QDK. On Ubuntu, you can do so by running sudo apt install libgomp1
, or yum install libgomp
on CentOS. For other distributions, please refer to your particular package manager.
Configure the QDK for your preferred environment from one of the following options:
- Download and install VS Code 1.52.0 or greater (Windows, Linux and Mac).
- Install the QDK for VS Code.
- Download and install Visual Studio 16.3 or greater, with the .NET Core cross-platform development workload enabled.
- Download and install the QDK.
Note
Although there is Visual Studio for Mac, the QDK extension is only compatible with Visual Studio for Windows.
- Enter the following at the command prompt
dotnet new -i Microsoft.Quantum.ProjectTemplates
Follow the instructions on the tab corresponding to your development environment.
If you are receiving an error "'npm' is not recognized as an internal or external command", in the below steps, install node.js including npm. Alternatively, use our the command line templates to create a Q# project , or use Visual Studio.
To create a new project:
- Click View -> Command Palette and select Q#: Create New Project.
- Click Standalone console application.
- Navigate to the location to save the project. Enter the project name and click Create Project.
- When the project is successfully created, click Open new project... in the lower right.
Inspect the project. You should see a source file named Program.qs
, which is a Q# program that defines a simple operation to print a message to the console.
To run the application:
- Click Terminal -> New Terminal.
- At the terminal prompt, enter
dotnet run
. - You should see the following text in the output window
Hello quantum world!
Note
Workspaces with multiple root folders are not currently supported by the VS Code Q# extension. If you have multiple projects within one VS Code workspace, all projects need to be contained within the same root folder.
Verify your Visual Studio installation by creating a Q# Hello World
application.
To create a new Q# application:
- Open Visual Studio and click File -> New -> Project.
- Type
Q#
in the search box, select Q# Application and click Next. - Enter a name and location for your application and click Create.
Inspect the project. You should see a source file named Program.qs
, which is a Q# program that defines a simple operation to print a message to the console.
To run the application:
- Select Debug -> Start Without Debugging.
- You should see the text
Hello quantum world!
printed to a console window.
Note
If you have multiple projects within one Visual Studio solution, all projects contained in the solution need to be in the same folder as the solution, or in one of its sub-folders.
Verify your installation by creating a Q# Hello World
application.
-
Create a new application:
dotnet new console -lang Q# -o runSayHello
-
Navigate to the application directory:
cd runSayHello
This directory should now contain a file
Program.qs
, which is a Q# program that defines a simple operation to print a message to the console. You can modfiy this template with a text editor and overwrite it with your own quantum applications. -
Run the program:
dotnet run
-
You should see the following text printed:
Hello quantum world!
Now that you have installed the Quantum Development Kit in your preferred environment, you can write and run your first quantum program.