要让纯linux命令行支持显示中文,需要安装zhcon,实际操作不易,几近崩溃,以此记录,本机Centos7。

首先需要先在windows上下载zhcon-0.2.5.tar.gz和zhcon-0.2.5-to-0.2.6.diff.gz

将安装包上传到虚拟机,我用的是Putty,也可以使用其他的,然后解压zhcon-0.2.5.tar.gz,最好是解压到一个熟悉的目录里,比如zhcon(先在根目录创建)。

解压命令:tar zxvf zhcon-0.2.5.tar.gz -C zhcon。

将zhcon-0.2.5-to-0.2.6.diff.gz移动到zhcon目录下(mv命令),在zhcon/zhcon-0.2.5下执行zcat ../zhcon-0.2.5-to-0.2.6.diff.gz | patch -p1(如果patch命令未找到可以使用yum -y install patch安装即可)。

然后在zhcon/zhcon-0.2.5下执行./configure。

执行完后输入make,按下enter,然后就开始纠错之旅

1.make报错:

centos7 运行sh文件_#include

 意思是'memset'在此作用域中未声明,这是因为缺少include头文件,添加即可:在src/display目录下的fblinear4.cpp文件中插入一行#include <cstring>,保存退出。

centos7 运行sh文件_centos7 运行sh文件_02

 

centos7 运行sh文件_#include_03

 2.make报错:

centos7 运行sh文件_linux_04

和上面一样,添加include头文件即可:在 src/display目录下的fblinear8.cpp插入一行#include <cstring>,保存退出。

centos7 运行sh文件_头文件_05

centos7 运行sh文件_centos_06

3.make报错:

centos7 运行sh文件_centos7 运行sh文件_07

同理, 添加include头文件即可:在src目录下的basefont.cpp插入一行#include <cstring>,保存退出。

centos7 运行sh文件_linux_08

centos7 运行sh文件_头文件_09

 

4.make报错:

centos7 运行sh文件_linux_10

在src目录下的graphdev.cpp插入一行#include <cstring>,另外定义一个函数int abs(int dx){return (dx<0?-dx:dx);}保存退出。

centos7 运行sh文件_centos_11

centos7 运行sh文件_#include_12

 

centos7 运行sh文件_centos_13

5.make报错:

centos7 运行sh文件_#include_14

在src目录下的window.cpp插入一行#include <cstring>,保存退出。

centos7 运行sh文件_头文件_15

centos7 运行sh文件_centos7 运行sh文件_16

6.make报错:

centos7 运行sh文件_linux_17

 将src目录下的winime.cpp中和变量p相关的unsigned int更改为unsigned long:

centos7 运行sh文件_头文件_18

为了方便找到unsigned int的位置,可以使用/unsigned int直接找到:

centos7 运行sh文件_centos_19

centos7 运行sh文件_#include_20

更改后:

centos7 运行sh文件_头文件_21

7.make报错:

centos7 运行sh文件_centos7 运行sh文件_22

错误原因:缺少ncurses包,解决方法:用root身份执行yum install ncurses ncurses-devel即可。

centos7 运行sh文件_centos7 运行sh文件_23

问题输入y即可。 

8.make报错:

centos7 运行sh文件_#include_24

在src目录下的zhcon.cpp插入一行#include <cstring>,保存退出。

centos7 运行sh文件_#include_25

centos7 运行sh文件_centos_26

 

9.make报错:

centos7 运行sh文件_#include_27

在src目录下的inputmanager.h插入一行#include <sys/select.h>,保存退出。

centos7 运行sh文件_linux_28

centos7 运行sh文件_头文件_29

10.make报错:

centos7 运行sh文件_头文件_30

在src目录下的inputclient.h插入一行#include <cstdlib>,保存退出。

centos7 运行sh文件_头文件_31

centos7 运行sh文件_头文件_32

11.make报错:

undefined reference to tgetent,undefined reference to tgetstr:

需要连接ncurses库,在src目录下的Makefile文件里面找到LIBS=开头的一行,在后面添加-lncurses。

centos7 运行sh文件_centos7 运行sh文件_33

centos7 运行sh文件_linux_34

 

排查完所有error后,再次make,终于成功了,然后再make install,顺利结束。

但是此时还是不能看见文件里的中文,还需要启动zhcon,启动方法:zhcon --utf8,

centos7 运行sh文件_centos7 运行sh文件_35

centos7 运行sh文件_头文件_36

 

能看到这个界面就算启动成功了。 

启动完成后,再去查看带中文内容的文件就能看见中文了,如果还是不行,就重启一下虚拟机再启动zhcon。

如果需要退出zhcon,只需要输入exit或者ctrl+D即可退出。