tags:

views:

187

answers:

4
+1  Q: 

emacs C and C++

Hi there,

I have some very specific questions related to emacs for building C applications:

1) How can I compile a file written in C/C++ using emacs.
2) How can I have something similar with MS Intellisense in emacs?
3) How can I add an C/C++ library to the compiler and emacs to know about it.

many thanks

+3  A: 
  1. M-x compile (see this SO question)
  2. M-/ (see this SO question, which is exactly the same)
  3. The same way you would w/out using Emacs
Trey Jackson
A: 

Emacs is an editor, not an IDE. It has a ton of 'extra' features and is very configurable for an editor - but it's really not meant to be an IDE. If you want an open-source IDE you might want to check out Eclipse.

Having said that - you can compile from within emacs in a number of ways: 1. Just open a shell in another buffer (M-x shell) and compile from there. 2. Set up a Makefile and use the M-x compile

I'm sure there are complicated ways to get the other behaviors - but you'd probably be better off using a real IDE.

Aaron
Emacs can be anything you want it to be. Even an IDE. What Emacs is really 'meant to be' is probably another more philosophical discussion.
cschol
As the saying goes, "emacs is a great programming environment. All it really needs is a decent text editor" ;-)
Steve Jessop
@cschol and all the downvoters, look, while you are technically right that "Emacs can be made to be an IDE", you are are overlooking the facts that 1) how easy it is for an Emacs beginner to get IDE features? Are CEDET/JDE installed and preconfigured out of the box? 2) Once you setup CEDET/JDE, well, how is Emacs then comparing against Eclipse/IDEA/VS feature-wise? Refactorings, anyone? I am using Emacs as my main tool, but, folks, let's be honest that declaring "Emacs is an IDE" is a stretch.
Laurynas Biveinis
@kastauyra: You can write code, compile and debug from within Emacs. That's enough to make it an IDE in my book, though it perhaps pales in comparison to other IDEs.
outis
@kastuauyra Not all software tools can to be learned in 5 minutes, nor should they be necessarily. Professional programmers will be using tools potentially their whole working lives, so it's worth investing time learning ones that have the flexibility and power to endure.
justinhj
@justinhj I did not say that Emacs should be so simple that it could be learned in five minutes. I am all for investing time in learning tools, which I am doing with Emacs, BTW. It's just that a lifelong learning of Emacs will give me ability to "refactor" my code with very clever regexps and keyboard macros, and that's it. Missing feature in a tool is a missing feature regardless of a tool user's skill level.
Laurynas Biveinis
+2  A: 

code completion - Semantic (from CEDET package), compilation - depends on what you use to compile, but basically you can use EDE package (from CEDET) to maintain & compile projects

Alex Ott
+1  A: 

Take a look at this blog post I made, which shows you how to write a cpp program in emacs. If you want tab completion you also need to learn to generate and use tags, and the M-/ button.

When programming using emacs however, you do more than emulate Developer Studio or Eclipse. Learning to use keyboard macros, and program in elisp, will empower you to write little utilities that take a few minutes to write and save many times that in drudge work.

justinhj