> For the complete documentation index, see [llms.txt](https://docs.aic-eec.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aic-eec.com/c-c++-for-embedded-programming/development-environment-preparation/virtual-studio-code-wsl.md).

# การเชื่อมต่อ 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
