Under Linux development environment to build

To be honest, for OIer, Linux is really a good development platform.

Here neither the hustle and bustle of the game, also did not bother advertising, gcc / g ++ already pre-installed, everything is ready for you ...... (???) even for everyday use, but also more than enough.

If not familiar, the novice friendly,do not knowNo Dev-C ++Other reasons, to abandon it, a bit too pity.

So, how to build a good development environment under Linux?

In the following, I will be divided into three parts narrative Linux development environment to build, and to recommend some of the more easy to use software for your daily use reference.

(Note: The following command, run in a terminal if due to dependencies error, please use. sudo apt install -fRepair command)

Machine environment: Ubuntu 14.04 LTS, GCC / G ++ 4.8.4

First, the compiler installation

GCC / G ++ install command:

sudo apt install gcc g++

Clang compiler:

sudo apt install clang

We needed to eat.

Second, the code editor

(Note: The following IDE software may not in the strict sense, but the same applies to the majority of their OIer. Enjoy IT! )

### No.1 entry level

1. Code::Blocks

(Sun drying myAccording to the United States

The IDE is open source, cross-platform, relatively easy to use, code completion feature is also very powerful!

Probably the only unfriendly place is a bar in English.

Installation command:

sudo add-apt-repository ppa:damien-moore/codeblocks-stable
sudo apt update
sudo apt install codeblocks

Ease of use: 8 minutes
Functional: 9
Scalability: 6 minutes

2. gedit

gedit comes with many Linux distributions, the NOI Linux is also allowed. After some configuration later, it is still very easy to use.

Of course, gedit only provides basic editing functions. Compile, debug / Code completion etc., it is not available.

Therefore, this can not usually used, examination standby.

Ease of use: 8 minutes
Functional: 7
Scalability: 6 minutes

3. Visual Studio Code

(OnlinecasualLooking map)

Many of my friends heard of Visual Studio, but because of its huge body mass and prohibitive (frequently 10 ~ 20G). So, you may wish to try this lightweight IDE it.

它拥有美观的界面,数以万计的扩展,可以轻松地搭建一个令人舒适的开发环境。最重要的是,它跨平台!!!

当然,它也是我最喜欢的代码编辑器之一(只是现在我没用它了,改用了vim) 。不过,它的调试功能并不是太好用,需要自己配置,请自行百度。

安装:上微软官网下载deb包,双击打开ubuntu软件中心安装即可。

在这里推荐几个扩展:

  1. C/C++
  2. C++ Intellisense
  3. Code Runner(运行代码用)
  4. One Dark Pro主题(用过Atom的人应该都知道)
  5. Material Theme(非常美观)
  6. Markdown All in One
  7. Settings Sync(自动同步配置)
  8. Python(对于某些人有用,当然频繁使用crayon的人应该也有点用处)

易用性:9分
功能性:9分
可扩展性:9分

No.2 进阶级

GNU Emacs

心动了?先别着急,这其实是配置过后的。

原版界面:

(一言难尽啊......)

安装命令:

sudo apt install emacs

Emacs,(所谓神的编辑器) 相信很多OIer都听说过,但却因为其清(chao)秀(chou)的界面望而却步。

不过,Emacs的可定制性弥补了他的缺点。通过一系列配置,你可以把它变成自己想要的样子,再加上几个一键编译的快捷键,岂不爽翻?

说到底,怎么配置Emacs呢?这篇文章可能可以帮到你:

emacs配置基础讲解

当然,你也可以自行百度。

不想费脑筋?把我的配置拿去:(F5一键编译,编译出的文件名为a.out)

(注:配置文件为~/.emacs,请将下面的文本复制后粘贴到此文件下)

(show-paren-mode 1)
(global-set-key (kbd "C-a") 'mark-whole-buffer)
(global-set-key (kbd "C-z") 'undo)
(global-set-key (kbd "RET") 'newline-and-indent)
(cua-mode t)
(show-paren-mode t)
(global-linum-mode t)
(blink-cursor-mode -1)
(setq kill-ring-max 200)
(setq default-cursor-type 'bar)
(setq default-tab-width 4)
(setq c-default-style "awk")
(set-background-color "gray15")
(set-foreground-color "gray")
(set-frame-parameter (selected-frame) 'alpha (list 85 50))
(defun your-g++-compile () (interactive) (compile (format "g++ %s -g -Wall -std=c++11" (buffer-file-name)))) 
(global-set-key (kbd "<f5>") #'your-g++-compile)

易用性:8分(熟悉后可以打9分)
功能性:9分
可扩展性:9.5分

No.3 大神级

看到这里,你应该知道我要说什么了吧?

没错,那就是上天入地、翻江倒海 (什么鬼) 、出神入化的——

Vim!

摘用度娘的一句话:

  • Vim是从 vi 发展出来的一个文本编辑器。代码补全、编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用,和Emacs并列成为类Unix系统用户最喜欢的文本编辑器。

而且插件丰富,扩展性极高!

安装命令:

sudo apt install vim

然额,它的原始界面似这样的:

(比Emacs好不了多少,一个宣传GNU,一个帮助可怜儿童)

更让人崩溃的是,这个vim居然不知如何使用!进入界面,一通乱打,却一个字也敲不进,更不知如何调主题、保存文件......

甚至无法退出!!!

先别急着关掉这篇博客,别急,我们慢慢来,这些问题都好解决。如果你熟悉了vim的操作方式,会发现编程效率极高。

那么,如何学习vim的操作方式?

别急着网上搜教程,你的vim自带了一个教程——vimtutor。
终端输入vimtutor,回车运行即可(还是中文版的,好评)。
学了这篇教程,差不多vim的基本操作都会了。

说完了操作,再说说配置(配置文件为~/.vimrc)

相对而言,vim配置比emacs简单多了。为什么呢?因为网上有人已经帮我们配置好了啊!

参见这个链接:vimplus

在此必须感谢vimplus的维护者chxuan。如果没有他,可能我们就无法轻松、快速地配置好vim。

不过,vimplus的配置没有什么一键编译,甚至不能从系统剪贴板复制、粘贴。
所以,附上我的附加配置( +c 复制, +v 粘贴, +x 剪切, 编译, 运行):
(复制后粘贴在.vim的最后)

hi Normal ctermfg=252 ctermbg=none
command -nargs=0 Compile !clear&&g++ "%" -o "%<" -Wall -std=c++11 -g
command -nargs=0 Run !clear&&time "./%<"
map <F5> <ESC>:w<CR> <ESC>:Compile<CR>
map <F6> <ESC>:w<CR> <ESC>:Run<CR>
map <leader>v "+gp
map <leader>c "+y
map <leader>x "+d
set mouse=a

配置后界面:

(还要打分么......)

易用性:5分(熟悉后可以打9.5分)
功能性:10分
可扩展性:10分

三、调试器

很多OIer们,想必都用过Dev-C++下的调试器。确实,Dev-C++下的调试器方便好用(除了不支持STL),但在Linux下,又有什么调试器可用呢?

1. gdb

gdb是一个CLI调试器,没有图形化界面,但在熟练使用后,是非常方便的。而且他拥有很多高级功能(如给断点设置一个条件,满足这个条件才在该断点停下来)。

启动方式:终端运行gdb [文件名] 即可。

教程吗,请自行百度。顺便提一句,gdb有个半图形化界面,用gdb -tui即可进入。

2.ddd

安装命令:

  sudo apt install ddd

ddd虽说是一个图形化调试器,但他界面真的极其怪异,Like this:

但是,它的功能真的非常强大,包括但不限于:

  • 图形化显示结构体
  • 图形化显示链表、二维数组(矩阵)、树、图
  • 显示变量变化图像
  • ...

当然,其也是可以配置的。请自行百度。

3.nemiver

这应该是三者之中,界面最好看、最友好的,但功能也最弱,对于一般调试需求也够了。

安装命令:

  sudo apt install nemiver

当然,可能有很多好用的软件,限于作者学识,没有在本文中提到。大家可以在评论区留言,给我一些适当的建议!

讲了这么多,希望能对大家有点用处!

蒟蒻第一次写博客,请大佬多多关照,顺便别忘点个赞再走哦!

Guess you like

Origin www.cnblogs.com/acceptedzhs/p/12111600.html