我想把我的编程视野扩展到Linux。一个好的、可靠的基本工具集很重要,还有什么比IDE更基本呢?

我可以找到这些SO主题:

轻量级IDE linux和 你使用什么工具来开发 Linux上的c++应用程序?

我并不是在寻找轻量级IDE。如果一个IDE值那么多钱,我就会为它付费,所以它不一定是免费的。

我的问题是:

Linux有什么好的c++编程IDE ?

最小值是相当标准的:语法高亮显示、代码完成(如智能感知或其Eclipse对应版本)和集成调试(例如basic 断点)。

我自己也搜索过,但是有太多了,几乎不可能手工区分好的和坏的,特别是对于像我这样在Linux中几乎没有c++编程经验的人来说。我知道Eclipse支持c++,而且我真的很喜欢Java的IDE,但是它对c++有什么好处吗?还有更好的吗?

第二篇文章实际上有一些很好的建议,但我遗漏的是,究竟是什么让建议的IDE对用户这么好,它的(缺点)优势是什么?

也许我的问题应该是:

根据您的经验,您建议使用哪种IDE,为什么?


当前回答

简短的回答是:选择您喜欢的任何“编辑器”,然后使用GDB控制台或简单的GDB前端来调试应用程序。调试器带有别致的ide,例如Netbeans对于C/ c++来说很糟糕。我使用Netbeans作为编辑器,Insight和GDB控制台作为调试器。

有了洞察力,您就有了一个漂亮的GUI和GDB的原始功能。

一旦您习惯了GDB命令,您就会开始爱上它,因为您可以做使用GUI永远无法做的事情。如果您使用的是GDB 7或更新版本,您甚至可以使用Python作为脚本语言。

这里的大多数人更关注ide的“编辑器”。然而,如果你正在用C/ c++开发一个大型项目,你可能会很容易地把70%以上的时间花在“调试器”上。高级ide的调试器至少落后于Visual Studio 10年。例如,Netbenas与Visual Studio有非常相似的接口。但是与Visual Studio相比,它的调试器有许多缺点。

Very slow to display even a array with only a few hundreds of elements No highlighting for changed value ( By default, visual studio shows changed values in the watch windows in red) Very limited ability to show memory. You cannot modify the source code then continue to run. If a bug takes a long time to hit, you would like to change the source and apply the changes live and continue to run your application. You cannot change the "next statement" to run. In Visual Studio, you can use "Set Next Statement" to change how your application runs. Although this feature could crash your application if not used properly, but it will save you a lot of time. For instance, if you found the state of your application is not correct, but you do not know what caused the problems, you might want to rerun a certain region of the your source codes without restarting your application. No built-in support for STL such as vector, list, deque and map etc. No watch points. You need to have this feature, when you need to stop your application right at the point a variable is changed. Intel based computers have hardware watch points so that the watch points will not slow down your system. It might takes many hours to find some hard-to-find bugs without using watch points. "Visual Studio" calls "watch pointer" as "Data BreakPoint".

这个清单可以长得多。

Netbeans或其他类似ide的缺点让我非常沮丧,所以我开始学习GDB本身。我发现GDB本身非常强大。广发银行并不具备上述所有的“缺点”。实际上,GDB非常强大,在许多方面甚至比Visual Studio还要好。我给你们看一个非常简单的例子。

例如,你有一个这样的数组:

struct IdAndValue
{
  int ID;
  int value;
};


IdAndValue IdAndValues[1000];

当应用程序停止时,您希望检查IdAndValues中的数据。例如,如果你想在数组中找到特定“ID”的序数和值,你可以创建一个像下面这样的脚本:

define PrintVal 
set $i=0
printf "ID = %d\n", $arg0
while $i<1000
  if IdAndValues[$i].ID == $arg0
    printf "ordinal = %d, value = %d\n", $i, IdAndValues[$i].vaue
    set $i++
  end
end
end

您可以在当前上下文中使用应用程序中的所有变量,包括您自己的变量(在本例中为$i)、传递的参数(在本例中为$arg0)以及所有GDB命令(内置或用户定义)。

使用GDB提示符中的PrintVal 1打印ID为“1”的值

顺便说一下,NetBeans确实附带了一个GDB控制台,但是通过使用控制台,您可能会使NetBeans崩溃。我相信这就是为什么控制台在NetBeans中默认是隐藏的

其他回答

简短的回答是:选择您喜欢的任何“编辑器”,然后使用GDB控制台或简单的GDB前端来调试应用程序。调试器带有别致的ide,例如Netbeans对于C/ c++来说很糟糕。我使用Netbeans作为编辑器,Insight和GDB控制台作为调试器。

有了洞察力,您就有了一个漂亮的GUI和GDB的原始功能。

一旦您习惯了GDB命令,您就会开始爱上它,因为您可以做使用GUI永远无法做的事情。如果您使用的是GDB 7或更新版本,您甚至可以使用Python作为脚本语言。

这里的大多数人更关注ide的“编辑器”。然而,如果你正在用C/ c++开发一个大型项目,你可能会很容易地把70%以上的时间花在“调试器”上。高级ide的调试器至少落后于Visual Studio 10年。例如,Netbenas与Visual Studio有非常相似的接口。但是与Visual Studio相比,它的调试器有许多缺点。

Very slow to display even a array with only a few hundreds of elements No highlighting for changed value ( By default, visual studio shows changed values in the watch windows in red) Very limited ability to show memory. You cannot modify the source code then continue to run. If a bug takes a long time to hit, you would like to change the source and apply the changes live and continue to run your application. You cannot change the "next statement" to run. In Visual Studio, you can use "Set Next Statement" to change how your application runs. Although this feature could crash your application if not used properly, but it will save you a lot of time. For instance, if you found the state of your application is not correct, but you do not know what caused the problems, you might want to rerun a certain region of the your source codes without restarting your application. No built-in support for STL such as vector, list, deque and map etc. No watch points. You need to have this feature, when you need to stop your application right at the point a variable is changed. Intel based computers have hardware watch points so that the watch points will not slow down your system. It might takes many hours to find some hard-to-find bugs without using watch points. "Visual Studio" calls "watch pointer" as "Data BreakPoint".

这个清单可以长得多。

Netbeans或其他类似ide的缺点让我非常沮丧,所以我开始学习GDB本身。我发现GDB本身非常强大。广发银行并不具备上述所有的“缺点”。实际上,GDB非常强大,在许多方面甚至比Visual Studio还要好。我给你们看一个非常简单的例子。

例如,你有一个这样的数组:

struct IdAndValue
{
  int ID;
  int value;
};


IdAndValue IdAndValues[1000];

当应用程序停止时,您希望检查IdAndValues中的数据。例如,如果你想在数组中找到特定“ID”的序数和值,你可以创建一个像下面这样的脚本:

define PrintVal 
set $i=0
printf "ID = %d\n", $arg0
while $i<1000
  if IdAndValues[$i].ID == $arg0
    printf "ordinal = %d, value = %d\n", $i, IdAndValues[$i].vaue
    set $i++
  end
end
end

您可以在当前上下文中使用应用程序中的所有变量,包括您自己的变量(在本例中为$i)、传递的参数(在本例中为$arg0)以及所有GDB命令(内置或用户定义)。

使用GDB提示符中的PrintVal 1打印ID为“1”的值

顺便说一下,NetBeans确实附带了一个GDB控制台,但是通过使用控制台,您可能会使NetBeans崩溃。我相信这就是为什么控制台在NetBeans中默认是隐藏的

我非常喜欢Ultimate++的IDE。它有一些被设计为与自己的库一起使用的特性(顺便说一下,如果你不想在GTK+或QT上购买,这是一个相当不错的工具包),但它与一般的c++项目一起工作得非常好。它提供了良好的代码补全、良好的语法着色、集成调试以及大多数现代ide支持的所有其他特性。

对这个问题有一个快速的跟进…

自从我开始使用Vim作为我的主要“GUI”已经有一个月了 在Linux下编程c++的工具。首先是学习 曲线确实有点陡,但过了一段时间,随着 正确的选项打开和脚本运行我真的 掌握诀窍了!

我喜欢如何塑造Vim以满足您的需求; 只需添加/更改键映射,Vim就变成了一个 高效的“IDE”。

在Linux上构建和编译c++程序的工具链是 也很直观。Make和g++是你需要的工具 使用。

调试器ddd并不是真的那么好,但是 也许是因为我还没有时间去掌握它 正常。

所以对于那些正在或正在寻找一个好的c++ IDE的人来说 Linux,就像我一样,你最好的赌注在于标准 Linux本身(Vim, g++, ddd)和你 真的应该至少尝试使用它们,然后再寻找 sonething别的……

最后但并非最不重要的,我真的想感谢康拉德 他的回答是,它真的帮我找到了自己的路 Linux开发环境,谢谢!

我也不会结束这个问题,所以大家可以 React或甚至添加新的建议或添加到 已经是很好的答案了……

你能再解释一下你的情况吗,你需要改变什么。也许你可以通过提供一些你使用的信息的链接给我指明正确的方向。

我的第一个来源实际上是工具的手册页。只要输入

$ man toolname

在命令行上($ here是提示符的一部分,而不是输入)。

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 documentation which 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.

我使用GVIM是因为我在这方面有一些(但不是很多)经验,关于Emacs或替代方案我不能说什么。我发现阅读别人的.gvimrc配置文件真的很有帮助。很多人把它放在网上。这是我的。

不要试图一次掌握所有的双utils,有太多的函数。但是要有一个大概的了解,这样你就知道将来需要什么东西的时候去哪里找了。但是,您应该知道g++和ld (GCC链接器工具,自动调用,除非显式阻止)的所有重要参数。

另外,我很好奇,编码时有代码完成和语法高亮吗?

语法高亮:是的,而且比Visual Studio好得多。代码完成:差不多。首先,我必须承认,我甚至在Visual Studio中都没有使用c++代码补全,因为(与VB和c#相比)它不够好。我现在不经常使用它,但是尽管如此,GVIM对c++有本地代码补全支持。结合ctags库和像taglist这样的插件,这几乎就是一个IDE。

实际上,是阿明·罗纳切的一篇文章激发了我的灵感。在阅读文章之前,看看文章末尾的截图!

在得到(语法)错误之前必须先编译吗?

是的。但这对于Visual Studio来说是一样的,不是吗(我从来没有用过Whole Tomato)?当然,语法高亮显示不匹配的括号,但仅此而已。

如何调试(再次考虑断点等)?

我使用gdb,这是一个命令行工具。还有一个叫做DDD的图形前端。gdb是一种现代的调试工具,可以做您在IDE中可以做的所有事情。唯一真正让我恼火的是读取堆栈跟踪,因为行没有缩进或格式化,所以当你使用很多模板时(我就是这样做的),很难扫描信息。但这些也会使ide中的堆栈跟踪变得混乱。

就像我说的,我很“荣幸”在高中时使用windows记事本和命令行Java编译器迈出了我在Java编程语言中的第一步,它是…嗯,噩梦!当然,当我把它和我当时学的其他编程课程进行比较时,我们有不错的IDE

您甚至不应该尝试将现代的全功能编辑器(如Emacs或GVIM)与Notepad进行比较。记事本是一个修饰的文本框控件,这真的使所有的不同。此外,在Linux和Windows中使用命令行是一种非常不同的体验。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 t in command mode) should work everywhere, and jumps to the next tab, or tab no. n if a number was given. Type :help gt to get more help.

至少对于Qt特定的项目,Qt Creator(来自Nokia/Trolltech/Digia)显示出很大的希望。