Jonas Byström
Jonas Byström

Reputation: 26179

How to change the working directory for build/debug in Emacs?

I'm trying to get accustomed to using Emacs for building and debugging, although I'm having some difficulties. My biggest problem right now is that I need to be in (e.g. have a file open in) the root directory to make -k my applications and I need to be in the binaries directory to run gdb MyApp.

Is it futile to try to get Ctrl+Shift+B to make -k -C <my_hard_coded_dir> and some type of ditto with F5 running gdb <MyApp> from my bin directory? Never mind if the shift key is to much of a hassle for Emacs.

Upvotes: 3

Views: 2104

Answers (3)

Alex Ott
Alex Ott

Reputation: 87249

I'm personaly use EDE to keep compilation settings for concrete projects, and create compile command on the fly. You can see how it works in my cedet config, starting with line 100

Upvotes: 0

Nathaniel Flath
Nathaniel Flath

Reputation: 16025

To specify what M-x make uses for compilation, you specify the compile-command variable.

(setq compile-command "make -c /path/to/makefile")

For your GDB stuff, the variable is gud-gdb-command-name, so

(setq gud-gdb-command-name "gdb --anotate=3 -cd /path/to/exec")

Upvotes: 5

Peter Miehle
Peter Miehle

Reputation: 6070

for compiling i use this spippet in my .emacs

(global-set-key [f2]   'compile)
(global-set-key [f3]   'next-error)
(setq compile-command "u: & cd \\gbceinspielen\\trunk\\src\\compile & make -k ")

the command "gdb" starts the debugger, but i do not know, wether there is an equivalent to compile-command.

Upvotes: 2

Related Questions