# Step 5 Configure and Build

## VSCode

Use the CMake Tools sidebar to configure, build and run your project is most convenient

## Configure

Click on the configure icon to configure your project.

<figure><img src="https://3464970502-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3JUKGJZ67JX02QZdPhsy%2Fuploads%2FdNe2B2PV5BjDnuJObD5w%2Fimage.png?alt=media&#x26;token=dc69e47c-0253-47eb-b331-53a448a4f6f3" alt=""><figcaption></figcaption></figure>

You may be asked to select your compiler and architecture. In this example we are using Visual Studio 2022 on a 64 bit platform.

You can also select to set the build version to be Debug or Release.

### Build

Click on the Build icon, it will start compiling your project. If successful, the exit code should be 0.

<figure><img src="https://3464970502-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3JUKGJZ67JX02QZdPhsy%2Fuploads%2FqiLDEUYBFIZazJ4vvpl1%2Fimage.png?alt=media&#x26;token=339c3f1b-620d-4307-8eb2-d3bc67b91221" alt=""><figcaption></figcaption></figure>

### After building

After building, a build directory appears.

If building is successful, you can see run01.exe in your Debug or Release directory.

<figure><img src="https://3464970502-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3JUKGJZ67JX02QZdPhsy%2Fuploads%2Ft9MusF9eRP9g07lpCIaZ%2Fimage.png?alt=media&#x26;token=e7dc0c18-d1e2-4986-af58-86e6c36a19a9" alt=""><figcaption></figcaption></figure>

### Alternatively, you can use the Command Pallette

Select View->Command Pallette

Type CMake:Build

<figure><img src="https://3464970502-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3JUKGJZ67JX02QZdPhsy%2Fuploads%2FcqXVnJcBS9yaLK12OUAJ%2Fimage.png?alt=media&#x26;token=a3a1a405-6111-48aa-a1da-cb32b5564f67" alt=""><figcaption></figcaption></figure>

Select your own compiler

I am using  Visual Studio 2022 with an x64 architecture, so I select Visual Studio 2022 with amd64, or you can choose "Scan for kits"

<figure><img src="https://3464970502-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3JUKGJZ67JX02QZdPhsy%2Fuploads%2F8Av0RIeoXvS0htTOVmYg%2Fimage.png?alt=media&#x26;token=219a4ea7-2d55-4ad8-a532-c30773c19da4" alt=""><figcaption></figcaption></figure>

###

## Visual Studio

Visual Studio supports CMake as well.&#x20;

You can use Visual Studio to directly open the project folder.

When you choose Build->Build All, it will create an out folder and putting all intermediate files in out/build

<figure><img src="https://3464970502-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3JUKGJZ67JX02QZdPhsy%2Fuploads%2Flo5ELVl4VqwcieItpNR4%2Fimage.png?alt=media&#x26;token=cc182189-ee8b-432a-aa43-b45c7d2163c2" alt=""><figcaption></figcaption></figure>

## CMake-GUI

Instead of the CMake extention in VSCodde, you can also use CMake-GUI to generate your Visual Studio project file.

Use CMake-GUI to open your project folder and specify your build folder.

After clicking on the Configure button, you can select your compiler.

<figure><img src="https://3464970502-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3JUKGJZ67JX02QZdPhsy%2Fuploads%2FWriWH3vauEaeJBW58Vjb%2F8e744026-ff17-4530-b023-5c772286fbbc.png?alt=media&#x26;token=298f12fe-4c83-4147-834c-a12f850f9d29" alt=""><figcaption></figcaption></figure>

Clicking Configure and Generate, will generate the Visual Studio project file

<figure><img src="https://3464970502-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3JUKGJZ67JX02QZdPhsy%2Fuploads%2FFWCvQ7JAwQQsuaaQi1kp%2Fimage.png?alt=media&#x26;token=7b85f2bc-ef46-4734-a31d-23888f6baddc" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3464970502-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3JUKGJZ67JX02QZdPhsy%2Fuploads%2FroE66FBSLobWI9U3ZdbO%2Fed093bd6-0e40-4e9a-905a-e6401fab617f.png?alt=media&#x26;token=b2b954d7-9dca-482a-bb1b-90c90f80ca1a" alt=""><figcaption></figcaption></figure>

The project files created are similar to what you have seen in VSCode. You can use Visual Studio to directly open the solution file.

From the project properties, you can see that the include directories, OpenGL and GLFW libraries are all added.

<figure><img src="https://3464970502-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3JUKGJZ67JX02QZdPhsy%2Fuploads%2FnqMJPTl3OFOyQJUMCEx3%2Facf784e9-252e-4b77-b2c9-02d1b224a79a.png?alt=media&#x26;token=02bb9f11-2790-4831-8a86-530a90d6fc4a" alt=""><figcaption></figcaption></figure>
