在Windows上使用Emacs编译C ++程序 [英] Compiling C++ Programs with Emacs on Windows

查看:164
本文介绍了在Windows上使用Emacs编译C ++程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Emacs进行基本的文本编辑,但截至今天,我试图将其用于c ++编译。我已经寻找过去几个小时关于这个问题,但是我仍然在打破路障的技术(我认为其中的一些与教程过时有关)。

I've been using Emacs for quite some time for basic text editing but as of today I am attempting to use it for c++ compilation. I have looked for the past few hours about how to go about this but I keep hitting roadblocks in their techniques (I think some of this is having to do with the tutorials being outdated).

基本上,我想做的就是能够编译通过'Mx编译'命令在Emacs中编写的C ++程序。

Basically, all I want to do is be able to compile C++ programs that I write in Emacs through the 'M-x compile' command.

到目前为止安装了Cygwin并下载了gcc的软件包。我已经尝试过在线教程中提出的一些其他解决方案,但是他们没有出现。

So far I have installed Cygwin and downloaded the packages for gcc. I have attempted some other solutions presented by tutorials online but they didn't pan out.

谢谢。

推荐答案

Mx编译命令调用外壳(例如linux bash ,Windows cmd.exe 等)运行 make 命令。在Windows上,我认为emacs默认为 cmd.exe shell(通过一个特殊的 C:/ Program Files / Emacs / emacs / bin / cmdproxy.exe 可执行文件)。

The M-x compile command calls out to a shell (e.g. linux bash, windows cmd.exe, etc) to run the make command. On windows I think emacs defaults to the cmd.exe shell (through a special C:/Program Files/Emacs/emacs/bin/cmdproxy.exe executable).

如果您希望您的 Mx编译使用不同的shell(可能是cygwin bash ),那么您需要通过更改 shell-file-name 变量或使用 SHELL 环境变量。您还需要确保通过更改 exec-path 变量(或使用$)来找到cygwin make c $ c> PATH 环境变量)

If you want your M-x compile to use a different shell (probably cygwin bash in your case) then you need to tell emacs through changing shell-file-name variable or using the SHELL environment variable. You will also need to make sure that the cygwin make is found by changing exec-path variable (or using PATH environment variable).

要执行此操作:

(setq shell-file-name "C:/cygwin/bin/bash.exe") 
(setq exec-path (cons "C:/cygwin/bin" exec-path))

您还可以查看 setup-cygwin.el 为cygwin设置和其他一些事情。

And you could also look at setup-cygwin.el to set this up and some other things for cygwin.

这篇关于在Windows上使用Emacs编译C ++程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆