需要使用的软件

编译Base需要有gcc、g++、make、perl这些工具,但其实我们只需要安装Strawberry Perl就可以了,安装完成后就有了MinGW的编译环境,足够编译安装EPICS了。

这里使用MinGW环境编译EPICS,不使用MSVC编译器。

安装 Strawberry Perl

这里选择 Strawberry Perl 5.32.1.1。经测试base-7.0.7可正常编译,后续版本的perl编译会报错。

直接安装即可,需要注意的是,安装路径不能有空格和中文,最好放在盘符的根目录下。
例:D:\Strawberry

安装完成后检查系统环境变量,查看系统Path环境变量是否有Strawberry Perl的路径。没有则手动添加,以安装在D盘为例。

1
2
3
D:\Strawberry\c\bin
D:\Strawberry\perl\site\bin
D:\Strawberry\perl\bin

其中D:\Strawberry\c\bin就是MinGW环境的路径。

查看Perl版本,检查一下是不是装好了。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
> perl -v

This is perl 5, version 32, subversion 1 (v5.32.1) built for MSWin32-x64-multi-thread

Copyright 1987-2021, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

编译安装EPICS Base

修改base源码目录下的startup/windows.bat文件。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
rem The location of Strawberry Perl (pathname).  If empty, Strawberry Perl
rem is assumed to already be in PATH and will not be added.  If nonempty,
rem Strawberry Perl will be added to PATH.
rem 设置Strawberry Perl安装路径
set _strawberry_perl_home=D:\Strawberry

rem The EPICS host architecture specification for EPICS_HOST_ARCH
rem (<os>-<arch>[-<toolset>] as defined in configure/CONFIG_SITE).
rem 设置编译主机架构,这里使用mingw
set _epics_host_arch=windows-x64-mingw

rem The install location of EPICS Base (pathname).  If nonempty and
rem _auto_path_append is yes, it will be used to add the host architecture
rem bin directory to PATH.
set _epics_base=C:\EPICS\base-7.0.7

rem Set the environment for Microsoft Visual Studio
rem 使用 rem 注释掉下面一行
rem call "%_visual_studio_home%\VC\Auxiliary\Build\vcvarsall.bat" x64

注意,编译需要使用命令行工具cmd,不能用powershell

1
2
3
cd base-7.0.7
.\startup\windows.bat
gmake -j16

等待编译完成。
编译完成后的工具在bin\windows-x64-mingw目录下。

测试使用:

1
2
3
cd bin\windows-x64-mingw
softIoc.exe
epics>