centos7 编写c++ helloworld程序并运行

 

安装perl支持

yum -y groupinstall perl*

 

#安装gcc

yum  -y install gcc

#安装g++

yum -y install gcc-c++

yum -y install libstdc++-devel

 

#yum -y install cmake3

#安装其它所需的包

安装一个老包ncurses,VIM会用到

yum -y install ncurses-devel

或者 sudo apt install libncurses5-dev

安装m4

wget http://mirrors.kernel.org/gnu/m4/m4-1.4.13.tar.gz 

tar -xzvf m4-1.4.13.tar.gz && cd m4-1.4.13 && ./configure -prefix=/usr/local && make && make install

 

安装autoconf

wget http://mirrors.kernel.org/gnu/autoconf/autoconf-2.65.tar.gz 

tar -xzvf autoconf-2.65.tar.gz && cd autoconf-2.65 && ./configure -prefix=/usr/local && make && make install

 

安装automake

wget http://mirrors.kernel.org/gnu/automake/automake-1.11.tar.gz 

tar xzvf automake-1.11.tar.gz && cd automake-1.11 && ./configure -prefix=/usr/local && make && make install

 

安装libtool

wget http://mirrors.kernel.org/gnu/libtool/libtool-2.2.6b.tar.gz 

tar xzvf libtool-2.2.6b.tar.gz && cd libtool-2.2.6b && ./configure -prefix=/usr/local && make && make install

 

安装Python2 开发包

yum install -y python-devel

wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0a1.tar.xz

tar xvf Python-3.6.0a1.tar.xz && cd Python-3.6.0a1 && ./configure -prefix=/usr/local && make && make install

 

安装git

sudo yum -y install git
安装svn

yum install -y subversion

 

#如果有需要安装python3,(VIM的YCM需要python支持,需要版本python2.6+ 或者 3,选择一个)

wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz

tar -xvJf  Python-3.6.2.tar.xz

cd Python-3.6.2

./configure prefix=/usr/local/python3

make && make install

安装VIM8.0

安装python3.6.5:

前戏:yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel make cmake gcc gcc-c++

我是用root直接操作的:

cd /usr/local/src

wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz

tar zxvf Python-3.6.5.tgz

cd Python-3.6.5.tgz

./configure --prefix=/usr/local/Python3.6.5 && make && make install

echo "export PATH=$PATH:/usr/local/Python3.6.5/bin" >> /etc/profile

source /etc/profile

python3 -V查看版本是否安装成功

更新vim

安装依赖包:

yum install -y ruby ruby-devel lua lua-devel luajit \
luajit-devel ctags git python-devel \
python36-devel tcl-devel \
perl perl-devel perl-ExtUtils-ParseXS \
perl-ExtUtils-XSpp perl-ExtUtils-CBuilder \
perl-ExtUtils-Embed libX11-devel

删除旧版本的vim:yum -y remove vim

 

git下载vim8.0(首先要安装git就不用说了吧):git clone https://github.com/vim/vim.git

进入vim的目录进行编译安装:

./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp=yes \
--enable-python3interp=yes \
--with-python3-config-dir=/usr/local/Python3.6.5/lib/python3.6/config-3.6m-i386-linux-gnu \
--enable-perlinterp=yes \
--enable-luainterp=yes \
--enable-gui=gtk2 \
--enable-cscope \
--prefix=/usr/local/Vim8.0 && make VIMRUNTIMEDIR=/usr/local/Vim8.0/share/vim/vim81 && make install

设置vim的环境:

echo "export PATH=$PATH:/usr/local/Vim8.0/bin" >> /etc/bashrc

source /etc/bashrc

查看vim版本信息:

vim --version

 

安装成功后:

--------------------------------------------------------------------------------------------

新建一个hello.cpp 文件

命令行:vim hello.cpp

按insert键  开始写 代码

#include<iostream>

using namespace std;

int main(){

   cout<<"Hello World" <<endl;

return 0;

}

按: 键  进入 vim 的命令行,输入 wq  保存退出

用 g++ hello.cpp -o hello  命令进行编译 

用 ./hello 运行,屏幕出现 HelloWorld

 

posted @ 2020-09-15 18:00  黑贝是条狗  阅读(1115)  评论(0编辑  收藏  举报