我最近开始使用 Linux 作为我的主要操作系统。在 Linux 中为 C 和 C++ 设置完整的编程环境需要哪些工具?
16 回答
标准的东西:
- 编译工具、gcc、gdb等。
- 某种编辑器/IDE(emacs、vim、eclipse)
- 分析工具
- 源代码控制(SubVersion、git 等)
- 特定于语言的工具,例如 python 的 easy_install(你说的是 C/C++,但对所有东西都一样)
- 一个网络服务器可能吗?Apache、Lighttpd、nginx
- 您将使用的任何库。你在做内核黑客吗?驱动开发?开源的?
Among others you should also have gprof and valgrind ( or something in it's class ).
这取决于您对“完整编程环境”的定义,以及您使用的是 C、C++ 还是两者兼有(C/C++ 是一个不应该使用的糟糕术语。要么是 C,要么是 C++)。
如果您正在寻找 IDE,Eclipse/CDT是根据我的经验最强烈推荐的 IDE(我实际上没有使用任何 IDE,所以我无法提供第一手建议)。
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.
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.
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-essential
From there you can install your SCM solution of choice and an IDE if you prefer or just use your favorite text editor.
最简单的答案是编辑器(任你选——至少已经有一个)和 gcc/g++。
如果您想要一个 IDE,那么在 SO 上会有很多与此相关的问题 :)(包括这个用于 Linux 的 C++ IDE?)。
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
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.
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
...
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.
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.
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).
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
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...
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
Two must haves are guake and pithos. I cant see how any one can have a list of dev tools without these.