适用于 Linux 的 C++ IDE?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C++ IDE for Linux?
提问by sven
I want to expand my programming horizons to Linux. A good, dependable basic toolset is important, and what is more basic than an IDE?
我想将我的编程视野扩展到 Linux。一个好的、可靠的基本工具集很重要,还有什么比 IDE 更基本呢?
I could find these SO topics:
我可以找到这些 SO 主题:
I'm not looking for a lightweightIDE. If an IDE is worth the money, then I will pay for it, so it need not be free.
我不是在寻找轻量级IDE。如果一个 IDE 物有所值,那么我会为它付费,所以它不一定是免费的。
My question, then:
那么我的问题是:
What good, C++ programming IDE is available for Linux?
有什么好的 C++ 编程 IDE 可用于 Linux?
The minimums are fairly standard: syntax highlighting, code completion (like intellisenseor its Eclipse counterpart) and integrated debugging (e.g., basic breakpoints).
最低限度是相当标准的:语法高亮、代码完成(如智能感知或其 Eclipse 对应物)和集成调试(例如,基本断点)。
I have searched for it myself, but there are so many that it is almost impossible to separate the good from the bads by hand, especially for someone like me who has little C++ coding experience in Linux. I know that Eclipse supports C++, and I really like that IDE for Java, but is it any good for C++ and is there something better?
我自己也找过,但是太多了,几乎不可能用手分清优劣,尤其是像我这样在Linux中几乎没有C++编码经验的人。我知道Eclipse 支持 C++,而且我真的很喜欢 Java 的 IDE,但是它对 C++ 有什么好处吗?还有更好的吗?
The second post actually has some good suggestions, but what I am missing is what exactly makes the sugested IDE so good for the user, what are its (dis)advantages?
第二篇文章实际上有一些很好的建议,但我缺少的是究竟是什么使 sugested IDE 对用户如此有益,它的(缺点)优势是什么?
Maybe my question should therefore be:
因此,也许我的问题应该是:
What IDE do you propose (given your experiences), and why?
您建议使用什么 IDE(根据您的经验),为什么?
采纳答案by Konrad Rudolph
Initially: confusion
最初:混乱
When originally writing this answer, I had recently made the switch from Visual Studio (with years of experience) to Linux and the first thing I did was try to find a reasonable IDE. At the time this was impossible: no good IDE existed.
最初撰写此答案时,我最近从 Visual Studio(具有多年经验)切换到 Linux,我做的第一件事就是尝试找到一个合理的 IDE。当时这是不可能的:没有好的 IDE 存在。
Epiphany: UNIX is an IDE. All of it.1
顿悟:UNIX 是一个 IDE。所有的。1
And then I realised that the IDE in Linux is the command line with its tools:
然后我意识到 Linux 中的 IDE 是带有工具的命令行:
- First you set up your shell
- Bash, in my case, but many people prefer
- fishor
- (Oh My) Zsh;
- and your editor; pick your poison — both are state of the art:
Depending on your needs, you will then have to install and configure several plugins to make the editor work nicely (that's the one annoying part). For example, most programmers on Vim will benefit from the YouCompleteMeplugin for smart autocompletion.
根据您的需要,您将必须安装和配置几个插件才能使编辑器正常工作(这是一个烦人的部分)。例如,Vim 上的大多数程序员将受益于用于智能自动完成的YouCompleteMe插件。
Once that's done, the shell is your command interface to interact with the various tools — Debuggers (gdb), Profilers (gprof, valgrind), etc. You set up your project/build environment using Make, CMake, SnakeMakeor any of the various alternatives. And you manage your code with a version control system (most people use Git). You also use tmux(previously also screen) to multiplex (= think multiple windows/tabs/panels) and persist your terminal session.
完成后,shell 是您与各种工具交互的命令界面 — 调试器 (gdb)、分析器(gprof、valgrind)等。您可以使用Make、CMake、SnakeMake或各种工具中的任何一个来设置您的项目/构建环境备择方案。并且您使用版本控制系统管理您的代码(大多数人使用Git)。您还可以使用tmux(以前也是屏幕)进行多路复用(= 考虑多个窗口/选项卡/面板)并保留您的终端会话。
The point is that, thanks to the shell and a few tool writing conventions, these all integrate with each other. And that way the Linux shell is a truly integrated development environment, completely on par with other modern IDEs. (This doesn't mean that individual IDEs don't have features that the command line may be lacking, but the inverse is also true.)
关键是,由于 shell 和一些工具编写约定,这些都相互集成。这样,Linux shell 就是一个真正集成的开发环境,完全可以与其他现代 IDE 相提并论。(这并不意味着单个 IDE 没有命令行可能缺乏的功能,但反之亦然。)
To each their own
各有各的
I cannot overstate how well the above workflow functions once you've gotten into the habit. But some people simply prefer graphical editors, and in the years since this answer was originally written, Linux has gained a suite of excellent graphical IDEs for several different programming languages (but not, as far as I'm aware, for C++). Do give them a try even if?—?like me?—?you end up not using them. Here's just a small and biased selection:
一旦您养成习惯,我怎么强调上述工作流程的功能都不为过。但是有些人只是更喜欢图形编辑器,并且在最初编写这个答案后的几年里,Linux 已经为几种不同的编程语言获得了一套出色的图形 IDE(但据我所知,对于 C++ 不是这样)。即使?-?像我一样?-?你最终不使用它们,也要试一试。这只是一个小而有偏见的选择:
- For Python development, there's PyCharm
- For R, there's RStudio
- For JavaScript and TypeScript, there's Visual Studio Code(which is also a good all-round editor)
- And finally, many people love the Sublime Text editorfor general code editing.
- 对于 Python 开发,有PyCharm
- 对于 R,有RStudio
- 对于 JavaScript 和 TypeScript,有Visual Studio Code(这也是一个很好的全能编辑器)
- 最后,很多人喜欢用Sublime Text 编辑器进行通用代码编辑。
Keep in mind that this list is far from complete.
请记住,此列表还远未完成。
1I stole that title from dsm's comment.
1我从 dsm 的评论中窃取了该标题。
2I used to refer to Vim here. And while plain Vim is still more than capable, Neovim is a promising restart, and it's modernised a few old warts.
2我以前在这里指的是 Vim。虽然普通的 Vim 仍然非常强大,但 Neovim 是一个很有希望的重启,它对一些旧的疣进行了现代化改造。
回答by Steve M
Checkout Netbeans, it's written in Java so you'll have the same environment regardless of your OS, and it supports a lot more than just C++.
结帐 Netbeans,它是用 Java 编写的,因此无论您的操作系统如何,您都将拥有相同的环境,并且它支持的不仅仅是 C++。
I'm not going to try to convince you, because I think IDEs can be a very personal choice. For me it improves my productivity by being fast, supporting the languages I code in and has the standard features you'd expect from an IDE.
我不会试图说服您,因为我认为 IDE 可能是一个非常个人的选择。对我来说,它通过快速、支持我编码的语言以及具有您期望从 IDE 获得的标准功能来提高我的工作效率。
回答by Imran
Soon you'll find that IDEs are not enough, and you'll have to learn the GCC toolchain anyway (which isn't hard, at least learning the basic functionality). But no harm in reducing the transitional pain with the IDEs, IMO.
很快你会发现IDE是不够的,无论如何你都必须学习GCC工具链(这并不难,至少学习基本功能)。但是,IMO 可以减少 IDE 的过渡痛苦。
回答by Konrad Rudolph
could you clarify a little bit more how it was for you, what you had to change. Maybe you could point me in the right direction by providing some links to the information you used.
你能不能再澄清一下你的感受,你必须改变什么。也许您可以通过提供一些指向您使用的信息的链接来为我指明正确的方向。
My first source were actually the tools' man
pages. Just type
我的第一个来源实际上是工具的man
页面。只需输入
$ man toolname
on the command line ($
here is part of the prompt, not the input).
在命令行上($
这里是提示的一部分,而不是输入)。
Depending on the platform, they're quite well-written and can also be found on the internet. In the case of make
, I actually read the complete documentationwhich took a few hours. Actually, I don't think this is necessary or helpful in most cases but I had a few special requirements in my first assignments under Linux that required a sophisticated makefile. After writing the makefile I gave it to an experienced colleague who did some minor tweaks and corrections. After that, I pretty much knew make
.
根据平台的不同,它们写得很好,也可以在互联网上找到。就 而言make
,我实际上花了几个小时阅读了完整的文档。实际上,我认为在大多数情况下这不是必需的或有帮助的,但是我在 Linux 下的第一次作业中有一些特殊要求,需要复杂的 makefile。编写 makefile 后,我将其交给了一位经验丰富的同事,他做了一些细微的调整和更正。在那之后,我几乎知道了make
。
I used GVIM because I had some (but not much) prior experience there, I can't say anything at all about Emacs or alternatives. I find it really helps to read other peoples' .gvimrc
config file. Many people put it on the web. Here's mine.
我使用 GVIM 是因为我之前在那里有一些(但不是很多)经验,我对 Emacs 或替代品一无所知。我发现阅读其他人的.gvimrc
配置文件真的很有帮助。很多人把它放在网上。这是我的。
Don't try to master all binutils at once, there are too many functions. But get a general overview so you'll know where to search when needing something in the future. You should, however, know all the important parameters for g++
and ld
(the GCC linker tool that's invoked automatically except when explicitly prevented).
不要试图一次掌握所有的binutils,功能太多了。但是,请获得一个总体概述,以便您将来在需要某些东西时知道去哪里搜索。但是,您应该知道g++
and ld
(自动调用的 GCC 链接器工具,除非明确阻止)的所有重要参数。
Also I'm curious, do you have code completion and syntax highlighting when you code?
另外我很好奇,你在编码时有代码完成和语法高亮吗?
Syntax highlighting: yes, and a much better one than Visual Studio. Code completion: yes-ish. First, I have to admit that I didn't use C++ code completion even in Visual Studio because (compared to VB and C#) it wasn't good enough. I don't use it often now but nevertheless, GVIM hasnative code completion support for C++. Combined with the ctagslibrary and a plug-in like taglistthis is almost an IDE.
语法高亮:是的,而且比 Visual Studio 好得多。代码完成:是- ISH。首先,我必须承认,即使在 Visual Studio 中我也没有使用 C++ 代码完成,因为(与 VB 和 C# 相比)它不够好。我现在不经常使用它,但是,GVIM具有对 C++ 的本机代码完成支持。结合ctags库和像taglist这样的插件,这几乎是一个 IDE。
Actually, what got me started was an articleby Armin Ronacher. Before reading the text, look at the screenshots at the end of it!
实际上,让我开始的是Armin Ronacher的一篇文章。在阅读正文之前,请先看一下文末的截图!
do you have to compile first before getting (syntax) errors?
在出现(语法)错误之前是否必须先编译?
Yes. But this is the same for Visual Studio, isn't it (I've never used Whole Tomato)? Of course, the syntax highlighting will show you non-matching brackets but that's about all.
是的。但这对 Visual Studio 来说是一样的,不是吗(我从未使用过 Whole Tomato)?当然,语法突出显示会向您显示不匹配的括号,但仅此而已。
and how do you debug (again think breakpoints etc)?
以及如何调试(再次考虑断点等)?
I use gdb
which is a command-line tool. There's also a graphical frontend called DDD
. gdb
is a modern debugging tool and can do everything you can do in an IDE. The only thing that really annoys me is reading a stack trace because lines aren't indented or formatted so it's really hard to scan the information when you're using a lot of templates (which I do). But those also clutter the stack trace in IDEs.
我使用的gdb
是命令行工具。还有一个名为DDD
. gdb
是一种现代调试工具,可以完成您在 IDE 中可以执行的所有操作。唯一真正让我烦恼的是阅读堆栈跟踪,因为行没有缩进或格式化,因此当您使用大量模板(我这样做)时很难扫描信息。但这些也会使 IDE 中的堆栈跟踪变得混乱。
Like I said, I had the 'pleasure' to set my first steps in the Java programming language using windows notepad and the command line java compiler in high school, and it was, .. wel a nightmare! certainly when I could compare it with other programming courses I had back then where we had decent IDE's
就像我说的,我很高兴在高中时使用 windows 记事本和命令行 java 编译器在 Java 编程语言中设置了我的第一步,那是,.. 一场噩梦!当然,当我可以将它与我当时拥有不错 IDE 的其他编程课程进行比较时
You shouldn't even try to compare a modern, full-feature editor like Emacs or GVIM to Notepad. Notepad is an embellished TextBox
control, and this really makes all the difference. Additionally, working on the command line is a very different experience in Linux and Windows. The Windows cmd.exe
is severely crippled. PowerShell is much better.
您甚至不应该尝试将 Emacs 或 GVIM 等现代的全功能编辑器与记事本进行比较。记事本是一个经过修饰的TextBox
控件,这确实使一切变得不同。此外,在 Linux 和 Windows 中使用命令行是一种非常不同的体验。窗户cmd.exe
严重残废。PowerShell 好得多。
/EDIT: I should mention explicitly that GVIM has tabbed editing(as in tabbed browsing, not tabs-vs-spaces)! It took me ages to find them although they're not hidden at all. Just type :tabe
instead of plain :e
when opening a file or creating a new one, and GVIM will create a new tab. Switching between tabs can be done using the cursor or several different shortcuts (depending on the platform). The key gt
(type g, then tin command mode) should work everywhere, and jumps to the next tab, or tab no. nif a number was given. Type :help gt
to get more help.
/EDIT:我应该明确指出GVIM 具有选项卡式编辑(如在选项卡式浏览中,而不是 tabs-vs-spaces)!我花了很长时间才找到它们,尽管它们根本没有隐藏。打开文件或创建新文件时,只需键入:tabe
而不是普通:e
,GVIM 将创建一个新选项卡。可以使用光标或几个不同的快捷方式(取决于平台)在选项卡之间切换。键gt
(键入g,然后t在命令模式下)应该在任何地方都可以使用,并跳转到下一个选项卡或选项卡号。n如果给出了一个数字。输入:help gt
以获得更多帮助。
回答by Greg Hewgill
Although I use Vim, some of my co-workers use SlickEditwhich looks pretty good. I'm not certain about integrated debugging because we wouldn't be able to do that on our particular project anyway.
虽然我使用 Vim,但我的一些同事使用看起来很不错的SlickEdit。我不确定集成调试,因为无论如何我们都无法在我们的特定项目中做到这一点。
SlickEdit does have good support for navigating large code bases, with cross referencing and tag jumping. Of course it has the basic stuff like syntax highlighting and code completion too.
SlickEdit 确实对导航大型代码库有很好的支持,具有交叉引用和标签跳转。当然,它也有语法高亮和代码完成等基本功能。
回答by Kristopher Johnson
As an old-time UNIX guy, I always use Emacs. But that has a pretty steep and long learning curve, so I'm not sure I can recommend it to newcomers.
作为一个老 UNIX 的人,我总是使用 Emacs。但这有一个非常陡峭和漫长的学习曲线,所以我不确定我是否可以向新手推荐它。
There really isn't a "good" IDE for Linux. Eclipse is not very good for C/C++ (CDT is improving, but is not very useful yet). The others are missing all the features you are going to be looking for.
对于 Linux,确实没有“好”的 IDE。Eclipse 对 C/C++ 不是很好(CDT 正在改进,但还不是很有用)。其他人缺少您将要寻找的所有功能。
It really is important to learn how all the individual tools (gcc, make, gdb, etc.) work. After you do so, you may find the Visual Studio way of doing things to be very limiting.
了解所有单个工具(gcc、make、gdb 等)的工作方式确实很重要。执行此操作后,您可能会发现 Visual Studio 的处理方式非常有限。
回答by wvdschel
I hear Anjuta is pretty slick for Gnome users. I played a bit with KDevelop and it's nice, but sort of lacking featurewise. Code::Blocks is also very promising, and I like that one best.
我听说 Anjuta 非常适合 Gnome 用户。我玩了一点 KDevelop,它很好,但有点缺乏功能。Code::Blocks 也很有前途,我最喜欢那个。
回答by dguaraglia
I quite like Ultimate++'s IDE. It has some features that were designed to use with their own library (which, BTW, is quite a nice toolkit if you don't want to buy on either GTK+ or QT) but it works perfectly well with general C++ projects. It provides decent code completion, good syntax colouring, integrated debugging, and all other features most modern IDEs support.
我非常喜欢Ultimate++的 IDE。它有一些设计用于与他们自己的库一起使用的功能(顺便说一句,如果您不想在 GTK+ 或 QT 上购买,这是一个非常好的工具包)但它与一般 C++ 项目完美配合。它提供了不错的代码补全、良好的语法着色、集成调试以及大多数现代 IDE 支持的所有其他功能。
回答by jassuncao
If you like Eclipse for Java, I suggest Eclipse CDT. Despite C/C++ support isn't so powerful as is for Java, it still offers most of the features. It has a nice feature named Managed Project that makes working with C/C++ projects easier if you don't have experience with Makefiles. But you can still use Makefiles. I do C and Java coding and I'm really happy with CDT. I'm developing the firmware for a embedded device in C and a application in Java that talks to this device, and is really nice to use the same environment for both. I guess it probably makes me more productive.
如果您喜欢 Eclipse for Java,我建议您使用 Eclipse CDT。尽管 C/C++ 支持不如 Java 强大,但它仍然提供了大部分功能。如果您没有使用 Makefile 的经验,它有一个名为 Managed Project 的不错的功能,可以让您更轻松地使用 C/C++ 项目。但是您仍然可以使用 Makefile。我从事 C 和 Java 编码,我对 CDT 非常满意。我正在为 C 中的嵌入式设备和 Java 中的一个应用程序开发固件,该应用程序与该设备对话,并且为两者使用相同的环境非常好。我想这可能会让我更有效率。
回答by rck
Not to repeat an answer, but I think I can add a bit more.
不重复答案,但我想我可以补充一点。
Slickeditis an excellent IDE.
Slickedit是一个优秀的 IDE。
It supports large code-bases well without slowing down or spending all its time indexing. (This is a problem I had with eclipse's cdt). Slickedit's speed is probably the nicest thing about it, actually.
The code completion works well and there are a large amount of options for things like automatic formatting, beautification and refactoring.
It does have integrated debugging.
It has plug-in support and fairly active community creating them.
In theory, you should be able to integrate well with people doing the traditional makefile stuff, as it allows you to create a project directly from one, but that didn't work as smoothly as I would have liked when I tried it.
In addition to Linux, there are Mac and Windows versions of it, should you need them.
它很好地支持大型代码库,而不会减慢速度或花费所有时间进行索引。(这是我在使用 eclipse 的 cdt 时遇到的问题)。实际上,Slickedit 的速度可能是它最好的地方。
代码完成效果很好,并且有很多选项可以用于自动格式化、美化和重构等。
它确实有集成调试。
它有插件支持和创建它们的相当活跃的社区。
从理论上讲,您应该能够与从事传统 makefile 工作的人很好地集成,因为它允许您直接从一个项目创建一个项目,但是当我尝试它时,这并不像我希望的那样顺利。
除了 Linux,还有 Mac 和 Windows 版本,如果您需要的话。