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

查看:131
本文介绍了在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 compile'命令在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 compile 命令调用shell(例如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 compile 使用不同的shell(可能是cygwin bash 你的情况下)然后你需要告诉emacs通过更改 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天全站免登陆