Jump to content
  • Advertisement
Sign in to follow this  
Halsafar

Linux C++ Using Emacs -- Need compiler

This topic is 4628 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay I'm beginning a project in C++ using Emacs (an OpenGL project). I am at a loss of what compilers I have to work with... Obviously I cannot begin with that question looming. I've never programmed C++ in Linux yet, I've been spoiled by Visual Studio the whole time. I feel stupid asking this because I compile programs a lot for installation... It just never clicked in... Any advice would be great.

Share this post


Link to post
Share on other sites
Advertisement
Before you start any project, here are a few tips.

1) Get familiar with your editor first. Emacs especially. If you don't know a basic understanding of the commands you won't get any work done.

2) Get familiar with the most commonly used gcc options, or at least know where to find them.

3) Introduce yourself to make. You should know how to write at least a simple makefile.

4) Not as important when you're starting, but it will be eventually... gdb.

LiDN is pretty cool too.

1 and 2 are probably the most important, but 3 and 4 will make your life easier.

Share this post


Link to post
Share on other sites
Yes, I fiddled with Emacs for a few days.
Read tons of tutorials.

I have gcc, but decided since I found first Intel's C++ Compiler to stick with that. So far the only difference is in calling it, 'icc'.

Makefiles, ugh....
WAsted hours on this one, still wasting time and still cannot get it to work...
I wrote a simple Hello.cpp which is the one-liner HelloWorld app

#include <iostream>
using std::cout

int main()
{
cout << "Hello World";
}


Care to show me a make file to compile this one file.

Share this post


Link to post
Share on other sites
When your projects get a little bigger, there are three ways to go:

1) automake -- generates extremely verbose make files for you, based on another syntax; uses recursive make

2) your own make system of custom make files; typically implemented using recursiv e make

3) self-generating, dependency-accurate, non-recursive cross-project make


Needless to say, I champion option 3 :-) I have a few sample make files that make that all "go" on my web site. The extra-cool part of it is that it does automatic dependency tracking (so that all files that include bar.h re-compile when you edit that file) -- that's NOT a standard feature for UNIX make files! And it does this without any pre-process or "makedepend" step! (NOT usually done on UNIX!) And it's fast! (not common among automated, recursive make systems)

Sorry, I'm getting away from myself there...

here's a command line that'll build and link your program using GCC:

gcc -o myprogram main.cpp -lstdc++


Share this post


Link to post
Share on other sites
I suggest ussing the g++ compiler for C++ programs. Also as far as text editors go, while emacs is fine, I suggest gvim/vim. Its very simple but also has many usefull features. And I couldn't help but notice you are only using cout. It's good practice to using namespace std that way you have access to all the iostream functions. And makefiles are kinda like scripts to do all the compiling for you

Share this post


Link to post
Share on other sites
Quote:
Original post by nethackpro
Also as far as text editors go, while emacs is fine, I suggest gvim/vim.


That's also my choice (I never could get my head around EMACS).
However, today I tried Eclipse's new CDT 3.0.1 (C++ plugin) and it was quite usable, more so than Visual C++ 2005 Express. It features code templates and that is what I am missing most in VC++ 2005 Express/VS 2003.

Share this post


Link to post
Share on other sites
As someone who uses emacs a lot, I actually suggest not starting with it. The big advantage of emacs is that I work a lot remotely. If you do all your editing on your local system, then the advantages of a console editor diminish a bit.

I highly suggest you start out using a GUI editor ('Kate' is pretty good). Emacs is really quite powerful, but you can get to that later... In the short term, you're going to have enough things getting in your way in such a new and different environment. One less obstacle will lead to a lot less frustation.

Oh, and use gcc. 4.0 is quite nice.

The primary difference between the 'gcc' and 'g++' executables is that 'g++' automatically links against the c++ standard library.

"gcc -lstdc++" == "g++"

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!