How to compile cpp with sublime

下次还敢
Release: 2024-04-03 08:57:21
Original
782 people have browsed it

You can use Sublime Text to compile C code: install the MinGW or Clang compiler and add it to the system path. Add a build system configuration in Sublime Text's settings, specifying the compiler and other parameters. Save the settings and press the shortcut key to compile the code. The compiled executable file will be saved in the source code file directory and can be run by entering the command in the terminal.

How to compile cpp with sublime

How to use Sublime text editor to compile C code

Sublime Text is a popular text editor. Supports multiple programming languages, including C. To use it to compile C code, you need to follow these steps:

1. Install the compiler

First, you need to install a C compiler such as MinGW or Clang. Once the installation is complete, make sure to add it to your system path.

2. Set up Sublime Text

Open Sublime Text, pressCtrl Shift P(Windows) orCmd Shift P(macOS) Open the Command Palette. Enter the following command:

Preferences: Open Settings (User)
Copy after login

In the settings file that opens, add the following code:

"build_systems": [ { "name": "C++ (g++)", "build_path": "${file_path}", "working_dir": "${file_path}", "compiler": "g++", "args": ["${file_basename_without_extension}.cpp"] } ]
Copy after login

Replacecompilerwith the path to your installed compiler.

3. Save and compile

Save the settings file. You can now compile C code in Sublime Text viaCtrl B(Windows) orCmd B(macOS).

4. Run the executable file

After compilation, the executable file will be saved in the same directory as the source code file. You can run it by entering the following command in the terminal:

./${file_basename_without_extension}
Copy after login

Note:

    ##Sublime Text also auto-completes code and provides syntax highlighting.
  • You can also use other plug-ins to enhance your C development experience, such as snippet managers and debugging tools.

The above is the detailed content of How to compile cpp with sublime. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!