【问题标题】:How to run c++ in atom with the atom script package?如何使用 atom 脚本包在 atom 中运行 c++?
【发布时间】:2021-02-20 08:16:11
【问题描述】:

我有一台装有 atom 1.52.0 和 g++ (MinGW.org GCC Build-2) 9.2.0 的 Windows 10 计算机。我可以使用 gpp 编译器在 Atom 中运行 c++ 程序,但我不喜欢程序输出在新窗口中而不是在 Atom 窗口底部的方式。我正在尝试使用脚本包设置 c++,但是当我使用脚本包运行程序时出现以下错误。

g++: error: /mnt/c/Users/user/Documents/USACO/2015-2016/December/Silver/test.cpp: No such file or directory
g++: fatal error: no input files
compilation terminated.

顺便说一句,我可以使用脚本包运行 java 程序。 screenshot

【问题讨论】:

  • 您是使用 WSL 还是其他原因导致 /mnt/c
  • 不确定 WSL 是什么意思(世界冲浪联盟?),所以可能不是。 “/mnt/c 的原因是什么?我也不知道 /mnt/c 是什么意思。
  • Linux 的 Windows 子系统。允许你在windows下运行linux。在像 /mnt/c 这样的 WSL 路径上存在并允许 linux 操作系统使用 windows 文件系统中的文件
  • 好吧,我知道 WSL 和 /mnt/c 是什么,但我为什么需要它们?也就是为什么我需要在windows下运行Linux?我只想运行 c++ 程序?
  • 我的意思是您的设置似乎是为 WSL 而不是 Windows 设置的。我不确定为什么。我主要使用 Visual Studio Community,有时也使用 Qt-Creator 或 VSCode。我不可能理解所有的代码编辑器/IDE。

标签: c++ atom-editor


【解决方案1】:

回复有点晚。但是对于那些从 Google 来到这里的人,在 script package page 上,它清楚地表明:

+---------+------------+-----------------+------------------+--------------------+---------------------------------------------------------+
| Grammer | File Based | Selection Based | Required Package |  Required in PATH  |                          Notes                          |
+---------+------------+-----------------+------------------+--------------------+---------------------------------------------------------+
| C++     | Yes        | Yes             |                  | xcrun clang++/g++  | Available only on macOS and Linux. Run with -std=c++14. |
+---------+------------+-----------------+------------------+--------------------+---------------------------------------------------------+

仅适用于 ma​​cOSLinux。使用-std=c++14 运行。

所以,它似乎不适用于 Windows。相反,您可以使用另一个名为 gpp-compiler 的包: https://atom.io/packages/gpp-compiler

在 Windows 上运行良好:

您需要安装MinGWadd it to your PATH

【讨论】:

  • 是的,这就是我最终所做的! gpp-compiler 包可以正常工作并运行 c++。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-16
  • 2016-06-03
  • 2022-01-19
  • 2021-09-28
  • 1970-01-01
相关资源
最近更新 更多