SlideShare a Scribd company logo
1 of 4
Download to read offline
1 | P a g e
HƯỚNG DẪN THIẾT ĐẶT ĐỂ CODE & COMPILE CODE
C/C++ TRÊN SUBLIME TEX2
1. Dành cho các trường hợp đã cài đặt DevC hay Code Block(tức là đã có MinGw trong máy)
Các bạn tìm tới thư mục bin có chứa file gcc.exe, sau đó copy lại đường dẫn thư mục này rồi
chuyển sang bước 3 (bỏ qua bước 2). Như trong hình dưới thì thư mục bin của máy mình nằm
ở đường dẫn C:Program FilesDev-CppMinGW32bin
2. Dành cho các bạn chưa có MinGw trong máy
Các bạn tải về MinGW tại đây link
Tiến hành cài đặt, khi cài đặt các bạn nhớ là chỉ đánh dấu chọn cài đặt mingw32-gcc-g++ thôi
nhé, vì mục đích chúng ta là học code C/C++ nên cài mấy cái kia là không cần thiết.
Chi tiết hướng dẫn cài đặt các bạn có thể xem tại đây link
Sau khi cài đặt xong MinGW các bạn tìm tới thư mục bin có chứa file gcc.exe và copy lại
đường dẫn thư mục này, ở đây mình cài MinGW vào ổ đĩa C:MinGW nên thư mục bin của
mình nằm ở đường dẫn C:MinGWbin
3. Các bạn truy cập vào Control PanelSystem and SecuritySystemAdvanced system
settings, hộp thoại System Propeties hiện ra, các bạn nhấn chọn Environment Variables...
2 | P a g e
Ở hộp thoại Environment Variables
-Mục User variables for PC-Name các bạn nhấn New, ở trường Variable name các bạn đặt
MinGW, ở trường Variable values các bạn paste đường dẫn thư mục bin mà các bạn lấy được ở
bước 1 hoặc bước 2 vào, sau đó nhấn OK
-Sau khi đã tạo xong Variable MinGW các bạn chọn nó, sau đó nhìn xuống mục System
Variables, các bạn tìm đến mục Path chọn Edit
3 | P a g e
Nhấn phím End để về cuối, khi đã về cuối các bạn thêm dấu chấm phẩy(;) sau đó paste đường
dẫn thư mục bin mà các bạn đã lấy được ở bước 1 hoặc 2 vàoOKOK
4. Mở sublime text lên, chọn ToolsBuild SystemNew Build System...
sau đó bạn xóa sạch nội dung trong file vừa tạo, copy và paste đoạn code sau vào
{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd": ["${file_path}/${file_base_name}.exe"]
}
]
}
Đoạn code ở trên đã được mình để ở github, các bạn có thể tìm thấy nó tại đây link
Tiếp theo các bạn lưu file này với tên chẳng hạn mình lưu MyC++.sublime-build
5. Ở mục ToolsBuild System bạn chọn Automatic(tự động chọn) hoặc MyC++(cái mà bạn tạo
ra ở bước 4)
4 | P a g e
6. Tạo file code chương trình đơn giản như sau, lưu lại với tên helloworld.cpp
#include <iostream>
#include <cstdlib>
int main(int argc, char const *argv[])
{
std::cout<<"Hello world!"<<std::endl;
system("pause");
return 0;
}
7. Nhấn Ctrl+B để tiến hành build file, nếu thành công ta nhận được thông báo
Nhấn Ctrl+Shift+B hoặc nháy đúp vào file exe vừa tạo ra để chạy chương trình, ta được kết quả
8. Để được hỗ trợ tốt hơn trong việc viết code C/C++, các bạn cài đặt thêm một số package sau
cho Sublime:
C++ 11
C++ Snippets
DocBlockr
SublimeAStyleFormatter
Have fun     

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Hướng dẫn Biên dịch code C/C++ trên Sublime text (Compile C/C++ code in sublime text)

  • 1. 1 | P a g e HƯỚNG DẪN THIẾT ĐẶT ĐỂ CODE & COMPILE CODE C/C++ TRÊN SUBLIME TEX2 1. Dành cho các trường hợp đã cài đặt DevC hay Code Block(tức là đã có MinGw trong máy) Các bạn tìm tới thư mục bin có chứa file gcc.exe, sau đó copy lại đường dẫn thư mục này rồi chuyển sang bước 3 (bỏ qua bước 2). Như trong hình dưới thì thư mục bin của máy mình nằm ở đường dẫn C:Program FilesDev-CppMinGW32bin 2. Dành cho các bạn chưa có MinGw trong máy Các bạn tải về MinGW tại đây link Tiến hành cài đặt, khi cài đặt các bạn nhớ là chỉ đánh dấu chọn cài đặt mingw32-gcc-g++ thôi nhé, vì mục đích chúng ta là học code C/C++ nên cài mấy cái kia là không cần thiết. Chi tiết hướng dẫn cài đặt các bạn có thể xem tại đây link Sau khi cài đặt xong MinGW các bạn tìm tới thư mục bin có chứa file gcc.exe và copy lại đường dẫn thư mục này, ở đây mình cài MinGW vào ổ đĩa C:MinGW nên thư mục bin của mình nằm ở đường dẫn C:MinGWbin 3. Các bạn truy cập vào Control PanelSystem and SecuritySystemAdvanced system settings, hộp thoại System Propeties hiện ra, các bạn nhấn chọn Environment Variables...
  • 2. 2 | P a g e Ở hộp thoại Environment Variables -Mục User variables for PC-Name các bạn nhấn New, ở trường Variable name các bạn đặt MinGW, ở trường Variable values các bạn paste đường dẫn thư mục bin mà các bạn lấy được ở bước 1 hoặc bước 2 vào, sau đó nhấn OK -Sau khi đã tạo xong Variable MinGW các bạn chọn nó, sau đó nhìn xuống mục System Variables, các bạn tìm đến mục Path chọn Edit
  • 3. 3 | P a g e Nhấn phím End để về cuối, khi đã về cuối các bạn thêm dấu chấm phẩy(;) sau đó paste đường dẫn thư mục bin mà các bạn đã lấy được ở bước 1 hoặc 2 vàoOKOK 4. Mở sublime text lên, chọn ToolsBuild SystemNew Build System... sau đó bạn xóa sạch nội dung trong file vừa tạo, copy và paste đoạn code sau vào { "cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"], "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir": "${file_path}", "selector": "source.c, source.c++", "variants": [ { "name": "Run", "cmd": ["${file_path}/${file_base_name}.exe"] } ] } Đoạn code ở trên đã được mình để ở github, các bạn có thể tìm thấy nó tại đây link Tiếp theo các bạn lưu file này với tên chẳng hạn mình lưu MyC++.sublime-build 5. Ở mục ToolsBuild System bạn chọn Automatic(tự động chọn) hoặc MyC++(cái mà bạn tạo ra ở bước 4)
  • 4. 4 | P a g e 6. Tạo file code chương trình đơn giản như sau, lưu lại với tên helloworld.cpp #include <iostream> #include <cstdlib> int main(int argc, char const *argv[]) { std::cout<<"Hello world!"<<std::endl; system("pause"); return 0; } 7. Nhấn Ctrl+B để tiến hành build file, nếu thành công ta nhận được thông báo Nhấn Ctrl+Shift+B hoặc nháy đúp vào file exe vừa tạo ra để chạy chương trình, ta được kết quả 8. Để được hỗ trợ tốt hơn trong việc viết code C/C++, các bạn cài đặt thêm một số package sau cho Sublime: C++ 11 C++ Snippets DocBlockr SublimeAStyleFormatter Have fun     