Home Development Tools sublime How to run c++ code in sublime

How to run c++ code in sublime

Apr 03, 2024 am 10:45 AM
sublime c++

Sublime 中运行 C++ 代码:安装 MinGW 或 Clang 编译器。创建 Sublime Text 项目。配置 MinGW:新建构建系统“C++ with MinGW.sublime-build”。配置 Clang:新建构建系统“C++ with Clang.sublime-build”。构建代码:按 Ctrl + B 或转到“工具”>“构建”。生成的可执行文件存储在项目文件夹中。

How to run c++ code in sublime

如何在 Sublime 中运行 C++ 代码

使用 MinGW 编译器

  1. 安装 MinGW:

    • 访问 MinGW 官方网站并下载适用于您操作系统的 MinGW 安装程序。
    • 安装 MinGW 并确保将其添加到系统路径中。
  2. 创建 Sublime Text 项目:

    • 打开 Sublime Text 并转到“File”>“New Project”。
    • 选择一个项目文件夹并输入项目名称。
  3. 配置构建系统:

    • 打开“Tools”>“Build System”>“New Build System”。
    • 输入以下内容并将其保存为“C++ with MinGW.sublime-build”:

      <code>{
        "cmd": ["g++.exe", "-std=c++17", "${file}", "-o", "${file_path}/${file_base_name}"],
        "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
        "selector": "source.c++, source.cpp"
      }</code>
      Copy after login
  4. 运行代码:

    • 确保您的代码已正确保存。
    • Ctrl + B 或转到“Tools”>“Build”来构建代码。
    • 生成的可执行文件将存储在项目文件夹中。

使用 Clang 编译器

  1. 安装 Clang 和 LLVM:

    • 访问 LLVM 网站并下载适用于您操作系统的 Clang 和 LLVM 安装程序。
    • 安装 Clang 并确保将其添加到系统路径中。
  2. 创建 Sublime Text 项目:

    • 按照适用于 MinGW 编译器的步骤进行操作。
  3. 配置构建系统:

    • 创建一个名为“C++ with Clang.sublime-build”的新构建系统:

      <code>{
        "cmd": ["clang++", "-std=c++17", "${file}", "-o", "${file_path}/${file_base_name}"],
        "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
        "selector": "source.c++, source.cpp"
      }</code>
      Copy after login
  4. 运行代码:

    • 按照适用于 MinGW 编译器的步骤进行操作。

The above is the detailed content of How to run c++ code in sublime. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What tools are good for making H5 pages What tools are good for making H5 pages Apr 06, 2025 am 06:33 AM

Suitable H5 page making tools are determined according to skill level: beginners use visual editors (such as online platforms or website building tools), advanced use code editors (such as Sublime Text) plus auxiliary tools (such as frameworks, package management tools, debugging tools), and master-level tools can be developed by themselves. Remember that choosing tools is auxiliary, the core is personal ability and continuous learning.

Usage of releasesemaphore in C Usage of releasesemaphore in C Apr 04, 2025 am 07:54 AM

The release_semaphore function in C is used to release the obtained semaphore so that other threads or processes can access shared resources. It increases the semaphore count by 1, allowing the blocking thread to continue execution.

C   and System Programming: Low-Level Control and Hardware Interaction C and System Programming: Low-Level Control and Hardware Interaction Apr 06, 2025 am 12:06 AM

C is suitable for system programming and hardware interaction because it provides control capabilities close to hardware and powerful features of object-oriented programming. 1)C Through low-level features such as pointer, memory management and bit operation, efficient system-level operation can be achieved. 2) Hardware interaction is implemented through device drivers, and C can write these drivers to handle communication with hardware devices.

Python vs. C  : Applications and Use Cases Compared Python vs. C : Applications and Use Cases Compared Apr 12, 2025 am 12:01 AM

Python is suitable for data science, web development and automation tasks, while C is suitable for system programming, game development and embedded systems. Python is known for its simplicity and powerful ecosystem, while C is known for its high performance and underlying control capabilities.

MySQL download prompts disk write errors how to deal with MySQL download prompts disk write errors how to deal with Apr 08, 2025 am 11:51 AM

MySQL download prompts a disk write error. The solution is as follows: 1. Check whether the disk space is insufficient, clean up the space or replace a larger disk; 2. Use disk detection tools (such as chkdsk or fsck) to check and fix disk errors, and replace the hard disk if necessary; 3. Check the target directory permissions to ensure that the user account has write permissions; 4. Change the download tool or network environment, and use the download manager to restore interrupted download; 5. Temporarily close the anti-virus software or firewall, and re-enable it after the download is completed. By systematically troubleshooting these aspects, the problem can be solved.

How to solve the problem of missing dependencies when installing MySQL How to solve the problem of missing dependencies when installing MySQL Apr 08, 2025 pm 12:00 PM

MySQL installation failure is usually caused by the lack of dependencies. Solution: 1. Use system package manager (such as Linux apt, yum or dnf, Windows VisualC Redistributable) to install the missing dependency libraries, such as sudoaptinstalllibmysqlclient-dev; 2. Carefully check the error information and solve complex dependencies one by one; 3. Ensure that the package manager source is configured correctly and can access the network; 4. For Windows, download and install the necessary runtime libraries. Developing the habit of reading official documents and making good use of search engines can effectively solve problems.

The Continued Use of C  : Reasons for Its Endurance The Continued Use of C : Reasons for Its Endurance Apr 11, 2025 am 12:02 AM

C Reasons for continuous use include its high performance, wide application and evolving characteristics. 1) High-efficiency performance: C performs excellently in system programming and high-performance computing by directly manipulating memory and hardware. 2) Widely used: shine in the fields of game development, embedded systems, etc. 3) Continuous evolution: Since its release in 1983, C has continued to add new features to maintain its competitiveness.

The Future of C   and XML: Emerging Trends and Technologies The Future of C and XML: Emerging Trends and Technologies Apr 10, 2025 am 09:28 AM

The future development trends of C and XML are: 1) C will introduce new features such as modules, concepts and coroutines through the C 20 and C 23 standards to improve programming efficiency and security; 2) XML will continue to occupy an important position in data exchange and configuration files, but will face the challenges of JSON and YAML, and will develop in a more concise and easy-to-parse direction, such as the improvements of XMLSchema1.1 and XPath3.1.

See all articles