views:

3103

answers:

15

I recently started using Linux as my primary OS. What are the tools that I will need to set up a complete programming environment in Linux for C and C++?

+1  A: 

The simplest of answers is an editor (take your pick - at least one is already on there) and gcc/g++.

If you want an IDE, there are a slew of questions related to that on SO :) (including this one http://stackoverflow.com/questions/24109/c-ide-for-linux).

warren
+4  A: 

Vi (or emacs), gcc , make
Tradiationally unix development is more commandline than ide. There are very good IDEs, the main ones are probably eclipse and kdevelop

Martin Beckett
+16  A: 

Standard stuff:

  • The compiler tools, gcc, gdb, etc.
  • Some sort of editor/IDE (emacs, vim, eclipse)
  • Profiling tools
  • Source Control (SubVersion, git, etc)
  • Language specific tools, like easy_install for python (you said C/C++, but the same goes for everything)
  • A web server maybe? Apache, Lighttpd, nginx
  • Any libraries you'll be using. Are you doing kernal hacking? Driver development? opengl?
swilliams
the ', etc.' is missing 'a build environment', like autotools, cmake, etc.
Adriano Varoli Piazza
+2  A: 

It depends on your definition of "Complete programming environment", and whether you are using C, C++, or both (C/C++ is an awful term that shouldn't be used. Either it's C, or C++).

If you are looking for an IDE, Eclipse/CDT is the most highly-recommended one from my experience (I don't actually use any IDE, so I can't offer first-hand advice).

If you can cope with command-line control (and in the end I find it makes things easier to do and doesn't take a whole lot of getting used to), a simple text editor with highlighting will suffice. I prefer KATE (part of KDE), as it features a built-in terminal as well as many features you would expect from an editor inside an IDE, like code folding and regex search/replace.

Many people also recommend Vim or Emacs, both of which are probably available through your distro's repositories. (Eclipse is probably available too, but in my experience the CDT is confusing to install via packages. YMMV). They are both ancient editors; and there is a powerful holy war between the two, so I won't get involved.

Your compiler should probably be GCC - on a Debian system, installing the g++ package as well as build-essential should be enough to get C++ going (build-essential should contain the gcc package required for C development). Whatever your distro, GCC is probably easily available or else already on your system.

coppro
+3  A: 

Seconding swilliams, I'd say the basics are:

  • an editor or IDE (I use vim),
  • a compiler (almost certainly gcc)
  • make, or maybe some other similar tool like ant if you want
  • a debugger (almost certainly gdb)
  • source control (I use subversion)
  • Standard unix utilities like grep and diff, but you have those already

Other than that, I'd say install as you go. Linux is more about little utilities that each do one thing than monolithic development environments that do everything. So if you find yourself needing something, you can always just install it, be that thing a memory profiler, a documentation generator, a bigger/smaller/more different editor, et cetera, et cetera.

Jacob B
+1  A: 

Kdevelop is a well regarded and well written IDE for Linux, installing it should get you every other tool you might want to develop with installed as well and and IDE to go with it.

By "every other tool" I mean gcc, grep, diff, autoconf et al should be grabbed by the package manager and installed at the same time, but I could be wrong. I don't have a standard distro on hand to test that with.

Personally, I use vim, but I have used kdevelop in the past.

vim/vi is handy because you know that some form of vi is always available on every unix platform.

  • I have to correct my post. I just looked at the package requirements for kdevelop on ubuntu... it does NOT appear to require gcc and install it automatically
lefticus
vi might be on every Unix, but it's not on every GNU/Linux - it's fully possible to set up a system with only emacs and no vim, especially if you're using a very customizable distro like Gentoo.
Branan
+5  A: 

Among others you should also have gprof and valgrind ( or something in it's class ).

BubbaT
+1  A: 

What distribution are you running?

In Ubuntu or any Debian based distribution you can issue the following command to install all the necessary tools.

sudo apt-get install build-essentials

From there you can install your SCM solution of choice and an IDE if you prefer or just use your favorite text editor.

mwilliams
build-essential without S
bortzmeyer
+1  A: 

If you want something very easy to use, with ability to import visual studio projects, and a feel much like VS, give Codeblocks a try. Its quick ( since its not Java based ) and in general works well.

DavidG
+1  A: 

Another great utility that you can use are *nix man pages. Each function in the C library has an associated man page.

For example:

man printf

man strncpy

...

Antonio Haley
A: 

I took an old windows laptop with a dead hard drive and replaced the hard drive then installed Ubuntu (linux / debian all in one handy release) on it. I had to burn the ubuntu installation files onto a cd first on another working computer.

Here's where I got my linux from (complete with desktop gui, very easy to install, lots of programs to use, it was my first linux but not my first unix):

http://www.ubuntu.com/getubuntu/download

Then i installed Netbeans for my integrated development environment (IDE) altough I am using it for java -- but it comes with c++ support as shown below:

http://www.netbeans.org/features/cpp/

I also installed mySql, you didn't ask, but that is another key component that completes my development environment.

Good luck to you.

A: 

On most distros, everything you need will be installed by default (very few don't include gcc, they all include some kind of editor). I generally do my development in Vim (or gVim, which is the graphical version -- the best of both worlds). For those times when I'm feeling the need for a "real" IDE, Eclipse with the Vim plugin is really nice. It's almost like working in Vim, except you get the Eclipse stuff -- again, best of both worlds. The Vim plugin for Eclipse that I'm using is not free, however :( I believe there is a free one, but the last time I tried it, it wasn't very good.

rmeador
"On most distros, everything you need will be installed by default" -- This is not as true as it once was.
Steve S
A: 

Personally I use Ubuntu w/ Eclipse CDT. Eclipse is what most people might think of as a Java IDE, but CDT is a set of extensions that really tune it for C/C++ development. It's smart enough to figure out what toolset to use (MacOSX GCC vs Linux GCC, for example).

Eclipse CDT Website

For best results, currently the 6.0 JRE for Ubuntu seems to have problems with recent Eclipse versions, so what I did was remove the 6.0 JRE and run:

apt-get install build-essential sun-java5-jre sun-java5-bin

Then grab the latest Eclipse from the website, unpack it in a directory.

As a final touch, edit the eclipse.ini file that comes with Eclipse and add this line to it:

-XX:CompileCommand=exclude,org/eclipse/core/internal/dtree/DataTreeNode,forwardDeltaWith

This will further stabilize the app, making it as rocksolid as Windows or Mac.

If you prefer commandline tools over GUI tools, some ones I use regularly:

  • CMake -- Portable build tool. It's easy to use and can output a variety of formats like Makefiles or Visual Studio files.

apt-get install cmake

  • Vim -- VI improved, if you want a text editor with some bells and whistles. Otherwise, just use 'nano', which comes with Ubuntu.

apt-get install vim

A: 

Twe options, you must make your decision now and never look back, or risk being burned at the stake:

a. Emacs b. vi(m)

Do not listen to any rational arguments before choosting... listen to the light inside yourself...

A: 

Install a lot of bell a whistles for the editor you choose, vi is usable but no fun. vim is fun, but vim with extras is great.

(And the same is true for Emacs even if that means installing tetris and a doctor ;-) )

/Johan

Johan