Using Visual Studio 6 C++ compiler from within Emacs
Asked Answered
S

8

8

I'm just getting started with c++ development and I would like to use emacs to write the code and then compile and run it from within emacs using the visual studio 6 compiler. I have already googled around a bit but just can't seem to find an explanation of how this is done. Any pointers?

Thanks for your help,

joerg

Seeto answered 4/6, 2009 at 20:3 Comment(1)
+1 for Emacs kicking out shitty editors ;)Kyla
A
4

I have done this as a matter of course over the past few years. There are two ways to do this:

  1. In the older versions of VS (including VS 6.0), there is a button to export the nmake file for the project. I do this on occasion and then use nmake to compile. I have

    (setq compile-command "nmake debug ")

    in my .xemace/init.el for this. You have to add the name of the nmake file, and nmake.exe has to be in your path. (BTW, I modified compilation-error-regexp-alist-alist to help moving through the errors. Let me know if you want this as well.)

  2. Newer versions of VS do not have the button to export the nmake file. For these I call devenv.com. In this case I have

    (setq compile-command "devenv.com /build Debug ")

    in my .xemacs/init.el. You have to add the name of the .sln file. Although I did not do this with VS 6.0, I believe that it may work as well.

Almazan answered 4/6, 2009 at 22:43 Comment(0)
S
3

I am not sure if you would consider merely swapping the text editor inside of Visual Studio with Emacs, but here is a sf.net project which does just that.

http://sourceforge.net/projects/visemacs/

Sylvia answered 4/6, 2009 at 20:9 Comment(0)
G
2

Checkout http://www.kuro5hin.org/story/2003/4/1/21741/10470

Gally answered 4/6, 2009 at 20:9 Comment(0)
A
2

As a followup to Andrew Stein's answer, to do a command line build on Visual Studio 6 without using nmake, use the syntax:

msdev wspname.dsw /make "project - Win32 Debug"
Adamek answered 26/3, 2010 at 18:19 Comment(1)
Note: For VS2005, the proper command is devenv.com ../slnname.sln /build "project - Win32 Debug" (the ".com" is important, if you want to see the output in your compilation buffer). Good instructions for setting up the environment variables inside emacs are available at emacswiki.org/MSVisualStudioFrogmouth
C
1

Visual Studio is an IDE

It uses the cl.exe compiler underneath.

Camillacamille answered 4/6, 2009 at 20:9 Comment(0)
K
0

We use emacs with GNU make (gmake), which is wrapped with our own gmake wrapper executable and it works very well.

Just set up simple a keybinding to invoke cl.exe on .c/.cpp files that you are compiling to build your .obj files. We have one keybinding for initializing a compile in a folder, which will make all .obj files that are not up to date, but this is purely handled by GNU make.

We also have other keybindings, e.g. for linking the executable and starting it etc.

Kyla answered 4/6, 2009 at 20:23 Comment(0)
C
0

A bit off topic, but why are you using visual studio 6? The compilers (as well as stripped down IDEs) for the current version of visual studio are available for free from Microsoft.

In either case, you can invoke the compiler from the commandline so it should be as simple as setting up a makefile.

Cytherea answered 4/6, 2009 at 21:34 Comment(0)
H
0

If you just want to set up a single file to compile then put this at the top of your file...

// -*- compile-command:"g++ test.cpp -g -lwinmm -o test.exe"; -*-

See my blog post on this

Of course you need to adjust to use CL.EXE and choose the appropriate arguments.

For launching make it's a bit trickier since you have to run make as if you were in the parent source directory, when you are editing a file further down the hierarchy.

The only way I know of to do that is to put this at the top of every file ...

// -*- compile-command:"nmake"; default-directory:"c:/projectroot/"; -*- 
Hachmin answered 4/6, 2009 at 23:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.