# การเชื่อมต่อ Virtual studio code เข้ากับ WSL

1. &#x20;เปิด Ubuntu ทำการ สร้าง folder ชื่อ “test\_project” ด้วยคำสั่งดังนี้

```
mkdir test_project
```

และ คำสั่ง ls เพื่อแสดงโฟล์ที่ได้สร้างไว้

![](https://paper-attachments.dropbox.com/s_8A1FED18EA21FC9C95036AEB616EAFA7245C9BB7CFEEC278232A34CCEF5C73AD_1606914351183_image.png)

2\. เปิดโปรแกรม Virtual studio code&#x20;

&#x20;     2.1 คลิ๊กตามภาพด้านล่าง

![หน้าต่างโปรแกรม VS Code](https://paper-attachments.dropbox.com/s_8A1FED18EA21FC9C95036AEB616EAFA7245C9BB7CFEEC278232A34CCEF5C73AD_1606912619525_Untitled.png)

&#x20;      2.2 เลือก Remote-wsl: Open Folder In WSL… ตามภาพด้านล่าง

![](https://paper-attachments.dropbox.com/s_8A1FED18EA21FC9C95036AEB616EAFA7245C9BB7CFEEC278232A34CCEF5C73AD_1606914884105_image.png)

&#x20;    2.3 เลือก โฟลเดอร์ชื่อ test\_project ที่เราได้สร้างจากขั้นตอนที่ 1&#x20;

![](https://paper-attachments.dropbox.com/s_8A1FED18EA21FC9C95036AEB616EAFA7245C9BB7CFEEC278232A34CCEF5C73AD_1606914915849_image.png)

&#x20;   2.4 ไปที่แถบเมนูของโปรแกรม Virtual studio code ที่ flie เลือก New Flie&#x20;

&#x20;   2.5 Copy โค้ดไปใส่ แล้วกด Ctrl+S เพื่อทำการ save ไฟล์ชื่อว่า “hello\_world.cpp”&#x20;

```
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
   vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
   for (const string& word : msg)
   {
      cout << word << " ";
   }
   cout << endl;
}
```

&#x20;  2.6 ไปที่แถบเมนู เปิด terminal เลือก New terminal จะแสดงหน้า terminal ดังภาพด้านล่าง

![](/files/-MNZ4XrCoBzid5-TVBLt)

&#x20;   2.7 พิมพ์คำสั่งลงใน terminal ดังนี้&#x20;

```
g++ hello_world.cpp -o hello
ls
./hello
```

![ผลการรันโปรแกรม hello](https://paper-attachments.dropbox.com/s_8A1FED18EA21FC9C95036AEB616EAFA7245C9BB7CFEEC278232A34CCEF5C73AD_1606915954228_image.png)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aic-eec.com/c-c++-for-embedded-programming/development-environment-preparation/virtual-studio-code-wsl.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
