Navigation

Sunday 25 August 2019

ⓩ - centos7 安装gdb和gdb server

首先卸载原有的gdb,sudo yum remove gdb
从gnu官网下载最新的gdb源文件,wget mirrors.ustc.edu.cn/gnu
tar -xf gdb-7.9.1.tar.xzcd gdb-7.9.1
sudo yum install texinfo
./configure
make
sudo make install
安装完了检查一下是否正确,gdb -v

源文件可以从http://ftp.gnu.org/gnu/gdb/这里下载最新的


*******************************************************************

使用vs2017远程调试linux, 网上博客一大堆,很多都是坑,大家小心:
注意安装gdbserver的命令是 yum install gdb-gdbserver 不是文中的gdbserver
2.linux各个组件安装后之后, 确定gcc是否符合标准,例如需要c11的,可能要升级gcc
3.Visual Studio Build成功后,Linux会有Projects文件夹, 但是此时并不表明你能成功Debug,或者运行
有可能需要升级libstdc++, 特别是之前升级了gcc时,一般都需要升级libstdc++ 
一般是因为使用了一些语法特性, 你的程序如果是printf(“Hello World”) 而且不引用什么库就不需要升级libstdc++也能调试
关于升级libstdc++: 
http://blog.csdn.net/norsd/article/details/51493742 
如果上面链接写的不详细,请移步: 
http://blog.csdn.net/hutianyou123/article/details/78133309






ⓩ - linux安装ssh和开启 ssh服务

1.安装SSH
如果你用的是redhat,fedora,centos等系列linux发行版,那么敲入以下命令:
sudo yum install sshd 或
sudo yum install openssh-server(由osc网友 火耳提供)

如果你使用的是debian,ubuntu,linux mint等系列的linux发行版,那么敲入以下命令:
sudo apt-get install sshd 或
sudo apt-get install openssh-server(由osc网友 火耳提供)

然后按照提示,安装就好了。
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

arch linux
  pacman -S openssh

这里写图片描述
2.开启ssh服务
service sshd start
  • 1
这里写图片描述
3.卸载服务
如果你用的是redhat,fedora,centos等系列linux发行版,那么敲入以下命令:
yum remove sshd
如果你使用的是debian,ubuntu,linux mint等系列的linux发行版,那么敲入以下命令:
sudo apt-get –purge remove sshd
  • 1
  • 2
  • 3
  • 4
这里写图片描述
注意:如果service sshd start
Redirecting to /bin/systemctl start sshd.service  启动不了。



service sshd start
Redirecting to /bin/systemctl start sshd.service
[root@localhost ~]# systemctl enable sshd.service
[root@localhost ~]# systemctl start sshd.service
[root@localhost ~]# systemctl status sshd.service
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-08-24 21:31:13 CST; 41min ago

     Docs: man:sshd(8)












解决方案:
service sshd start
Redirecting to /bin/systemctl start sshd.service
[root@localhost ~]# systemctl enable sshd.service
[root@localhost ~]# systemctl start sshd.service
[root@localhost ~]# systemctl status sshd.service
 sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-08-24 21:31:13 CST; 1 day 6h ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 39072 (sshd)
    Tasks: 1
   CGroup: /system.slice/sshd.service
           └─39072 /usr/sbin/sshd -D

Saturday 24 August 2019

ⓩ - Centos7下gcc安装以及如何升级





How To Install GCC on CentOS 7


Spread the love
yum install gcc
In this tutorial, we will take a look at how to install GCC on CentOS 7. GCC or GNU Compiler Collection is released by the Free Software Foundation and as the name suggests, it is a very useful collection of programming compilers such as C, C++, Objective-C, Objective-C++, Fortran, Java, Go and Ada. GCC is an official compiler of the GNU operating system but also it is a standard compiler on many Unix operating systems such as Linux. Installing GCC on CentOS 7, is really an easy task and it shouldn’t take more than 10 minutes.

1. Update the server

First of all log in to your CentOS 7 VPS via SSH as user root
ssh root@IP_Address -p Port_number
and make sure that all installed packages on the server are up to date
yum -y update

2. Install GCC from repository

GCC can be easily installed from the official CentOS repositories. Run the following command to install GCC on your server
yum -y install gcc
Once the installation is completed, you can the version of GCC installed on your server
gcc --version

gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
As might be seen from the output, the GCC version distributed by CentOS 7 is 4.8.5 which is not the latest version of GCC.
You may also want to install gcc-c++. It will automatically include the C++ library and compile files with extensions that indicate they are C source as C++, instead of as C.
yum -y install gcc-c++

3. Install GCC from source

If you need a newer version of GCC than the one distributed by the official CentOS 7 repositories you can install it from source.
It is highly recommended to start a screen session before starting the installation. Run the following command
screen -U -S gcc
Download the tarball of the GCC version you want to install. In our example we will use GCC version 7.3.0
wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-7.3.0/gcc-7.3.0.tar.gz
Unpack the tar archive and change the current working directory
tar zxf gcc-7.3.0.tar.gz
cd gcc-7.3.0
Install bzip2 and run the ‘download_prerequisites’ script to download some prerequisites needed by GCC. You have to run this from the top level of the GCC source tree.
yum -y install bzip2
./contrib/download_prerequisites
Once the prerequisites are downloaded execute the following command to start configuring the GCC build environment
./configure --disable-multilib --enable-languages=c,c++
Once it is completed, run the following command to compile the source code. It may take a few hours for the compilation to complete, so sit back and relax.
make -j 4
make install

4. Verify GCC installation on CentOS 7

After the compilation process is completed. You can check if GCC is properly installed.
gcc --version

gcc (GCC) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.