c++ - sclite(SCTK) `make check`故障,C++/perl/Cygwin,可以安全使用Perl4的东西吗?

标签 c++ perl makefile kaldi perl4

我目前正在尝试安装NIST的sclite,它是SCTK 2.4.0的一部分(githubnewer version)。我正在尝试在Cygwin中的bash上安装。使用make完成安装。

我已经跳过了安装的make configuremake all部分。这并非没有付出任何努力(请参阅first(file not recognized)和second(template / scoping)问题的SO帖子)。当我进入安装的make check部分时,通过了许多检查/测试,但是随后出现以下错误。

Testing acomp.pl
   No tests defined for acomp.pl
make[2]: Leaving directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/acomp'
(cd def_art; make check)
make[2]: Entering directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/def_art'
Testing def_art.pl
   def_art.pl passed without tests
make[2]: Leaving directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/def_art'
(cd hubscr; make check)
make[2]: Entering directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/hubscr'
Testing hubscr.pl
./RunTests.pl
   Running test 'test1-sastt', operation 'test', options '-G -f rttm -F rttm -a', directory 'test1-sastt.test'
      Executing command
Error: unable to get the version for program def_art.pl with the command 'def_art.pl' at ../hubscr.pl line 419.
Error: Execution failed at ./RunTests.pl line 30.
make[2]: *** [makefile:20: check] Error 2
make[2]: Leaving directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/hubscr'
make[1]: *** [makefile:68: checkFast] Error 2
make[1]: Leaving directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src'
make: *** [makefile:52: check] Error 2

我已经做了一些研究(如下所述),并且已经能够克服这个问题。但是,这涉及包括一些过时的perl模块(Perl4)。

我的第一个问题是如何解决此错误或如何跳过测试的那部分。我已经能够解决该错误,并且如果人们认为它是安全的,我将其作为答案。请注意,解决此问题后,make check还有另一个问题,但最后我提到了如何克服该问题。

我想知道使用旧的Perl(Perl4::CoreLibs)是否安全和/或良好的编程习惯。更改源代码以使用Perl5更好吗?

共有更好的方法吗?

我想确定的一件事是,在make check行的下方没有关键测试,可能会失败。

系统详情
$ uname -a
CYGWIN_NT-6.1 CAP-D-ENG-INT3 2.10.0(0.325/5/3) 2018-02-02 15:16 x86_64 Cygwin
$ bash --version
GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin) ...
$ gcc --version
gcc (GCC) 6.4.0 ...
$ g++ --version
g++ (GCC) 6.4.0 ...
$ make --version
GNU Make 4.2.1
Built for x86_64-unknown-cygwin ...
$ systeminfo | sed -n 's/^OS\ *//p'
Name:                   Microsoft Windows 7 Enterprise
Version:                6.1.7601 Service Pack 1 Build 7601
Manufacturer:           Microsoft Corporation
Configuration:          Member Workstation
Build Type:             Multiprocessor Free

我的尝试/研究

从上面的输出中,我们使def_art.pl通过了检查,因为没有检查-“def_art.pl passed without tests”。但是,接下来检查的是hubscr.pl失败。错误来自def_art.pl

要做的显而易见的事情似乎是运行def_art.pl,我这样做了。
$ ./src/def_art/def_art.pl
Can't locate getopts.pl in @INC 
(@INC contains: /usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads /usr/local/share/perl5/site_perl/5.26 /usr/lib/perl5/vendor_perl/5.26/x86_64-cygwin-threads /usr/share/perl5/vendor_perl/5.26 /usr/lib/perl5/5.26/x86_64-cygwin-threads /usr/share/perl5/5.26) 
at ./src/def_art/def_art.pl line 40.

因此在我看来,这是一个已弃用的perl文件(或模块,或其他)。

我进行了进一步的挖掘,在2014年的kaldi讨论中找到了this discussion。(kaldi是使用SCTK评分系统的语音识别工具包)。我认为讨论中有3个部分特别相关,我将链接这些部分(firstsecondthird)。我将在这里插入零件:

def_art.pl is looking for getopts.pl which I coudn't find on my machine!

... [T]hese are legacy packages that are no longer supported in recent versions of Perl 5. I don't think we should accept a dependency on them. They have been deprecated since the beginning of Perl 5. Instead of 'require "getopt.pl"', we should be doing use Getopt::Std (note: modern perl code should not call "require" for system packages). There is a similar issue with "flush.pl" in the Perl scripts. I don't know what the Perl 5 package name is. ... There are several places where this occurs.



我最终发现 getopts.pl 都可以提供flush.plPerl4::CoreLibs。我在本网站上引用了用于wget的URL。显然,在其他*NIX发行版中,可以使用软件包管理器,例如
apt-get install libperl4-corelibs-perl

要么
yum install perl-Perl4-CoreLibs

但是我找不到通过apt-cyg进行的安装。如“我正在做什么”部分中所述,我能够从tarball安装它们。

再说一次我的主要问题:这是安全/良好的编程习惯吗?有更好的解决方案吗?

如果有更好的解决方案(使用Perl 5),似乎this link可能会引导它。

其他可能相关的链接:有关flush.pllink_{n}link{n+1},有关getopts.plPerl4::CoreLibslink_{n+2}link_{n+3}

我在做什么
$ mkdir perl_added

$ cd perl_added

$ wget http://search.cpan.org/CPAN/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.004.tar.gz

$ tar -xzf Perl4-CoreLibs-0.004.tar.gz  

$ cd Perl4-CoreLibs-0.004

我没有使用一次性命令行,环境变量添加内容将该目录的lib子目录添加到PERLLIB环境变量中,而是执行了以下操作。

/usr/lib目录中创建一个新目录,然后将文件移到该目录中
$ stat /usr/lib/libperl4-corelibs-perl
stat: cannot stat '/usr/lib/libperl4-corelibs-perl': No such file or directory
# Checked that the directory didn't already exist. It didn't exist.

$ mkdir /usr/lib/libperl4-corelibs-perl

# Make each file executable, then move it into the new directory
# I'd like to come back and explain this.
$ find ./lib -type f -name "*.pl" -print0 | xargs -I'{}' -0 \
bash -c 'new_dir=/usr/lib/libperl4-corelibs-perl/; chmod +x {}; \
mv {} ${new_dir}'

最后,通过在perl中添加以下行,使每次使用终端时该目录都成为~/.bashrc搜索路径的一部分
此命令将路径添加到PERLLIB环境变量。不同版本的Linux具有用于添加到环境变量的不同语法,确保确定您的含义!
export PERLLIB="/usr/bin/libperl4-corelibs-perl:$PERLLIB"

我为此运行的命令是
$ echo -e "\n\n## Allow Perl to use the files in Perl4::CoreLibs" >> $HOME/.bashrc

$ echo -e "export PERLLIB=\"/usr/lib/libperl4_corelibs_perl:$PERLLIB\"" >> $HOME/.bashrc

$ source $HOME/.bashrc

(感谢@melpomene指出当前版本为0.004,而不是0.003。)

之后,我返回到安装的基本文件夹,并运行make cleanmake configmake allmake check

那确实使我在make check中走得更远,但不是很远。

我想知道使用旧的Perl(Perl4::CoreLibs)是否安全和/或良好的编程习惯。更改源代码以使用Perl5更好吗?

附言完成所有这些操作后,您可能想返回并删除解压缩所有内容的文件夹。就我而言:
rm -rf /path/to/where/I/started/perl_added

结果/后续步骤

一堆测试通过了,然后
(cd hubscr; make check)
make[2]: Entering directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/hubscr'
Testing hubscr.pl
./RunTests.pl
   Running test 'test1-sastt', operation 'test', options '-G -f rttm -F rttm -a', directory 'test1-sastt.test'
      Executing command
Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/{_recursive_/_recur_{ <-- HERE _sive_/_si_ve_}_}/ at ../../md-eval/md-eval.pl line 1099, <DATA> line 12.
Error: MDEVAL failed
      Command: md-eval.pl -nafcs -c 0.25 -o  -r sastt-case1.ref.rttm.filt -s sastt-case1.sys.rttm.filt -M sastt-case1.sys.rttm.filt.mdeval.spkrmap 1> sastt-case1.sys.rttm.filt.mdeval at ../hubscr.pl line 679.
Error: Execution failed at ./RunTests.pl line 30.
make[2]: *** [makefile:20: check] Error 255
make[2]: Leaving directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/hubscr'
make[1]: *** [makefile:68: checkFast] Error 2
make[1]: Leaving directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src'
make: *** [makefile:52: check] Error 2

也许this会有所帮助。我将为此问题发布separate question,或者,如果解决方案很快,我将在此帖子上添加解决方案。

最佳答案

更好的方法

(实际上,有几种更好的方法。请参阅我在问题下方的评论,以了解kaldi解决方案。)

与同事和 friend 交谈时,似乎对Perl4没有什么不安全的地方。我确实找到了一种更好的方式来“安装”它们,但是我将把注释留在问题中,用tarball,PERLPATH等显示“很长的路要走”。

检查您是否有CPAN

$ which cpan

如果看到以which: no cpan in (...)开头的内容,则很可能没有。尝试安装perl。对我来说,在Cygwin上,
$ apt-cyg install perl

(如果需要,请安装apt-cyg,有关说明,请参阅here。)

您可能不必安装Perl。您可能会看到类似/usr/bin/cpan的输出作为which cpan的输出。如果是这样,那你就很好。在命令提示符下输入cpan
$ cpan

如果这是您的第一次,它将询问有关配置的许多问题。每次我都按“Enter”键接受默认值,我最终得到如下提示:
cpan shell -- CPAN exploration and modules installation (v2.18)
Enter 'h' for help.

cpan[1]> 

在那里,我进入
cpan[1]> install Perl4::CoreLibs

安装将继续。完成后,您将可以键入exit并按“Enter”,这将使您返回bash命令提示符。
cpan[2]> exit
Lockfile removed.

$

此时,make check仍然会阻塞,但是安装将成功完成。如果您想让make check一直通过,请转到下面的“获取过去的make check”部分。不过,此时您可以执行该过程的最后两个步骤。
$ make install

此时,我将安装路径添加到了PATH变量中。希望我能够加入有关该过程的链接。 Here是一次性解决方案。
$ export PATH=/path/to/sctk/bin:$PATH

Here是一个持久的解决方案。

现在,对于安装过程的最后一步:
$ make doc

make doc之后,我确保man页面可用。我看了看机器,直到找到其他man文件所在的地方。 (对不起,我没有系统的方法,只是查看了很多地方。)对我而言,在Cygwin上,目录为/usr/man/man1
我进入了doc目录
cd doc

并将所有文件复制到我找到的目录中
cp -r ./* /usr/man/man1/

请注意,目录中现在也有htmlhtm文件,它们也提供了文档。

通过`make check`

因此,您真的希望看到它顺利进行。您需要更改以下文件:src/hubscr/RunTests.pl
最初它具有以下开头,我已使用head命令进行了显示。
$ head -n 15 src/hubscr/RunTests.pl
#!/usr/bin/perl -w
use strict;
my $operation = (defined($ARGV[0]) ? $ARGV[0] : "test");
sub runIt{
my ($op, $testId, $options, $glm, $hub, $lang, $ref, $systems) = @_;
my $baseDir = $testId.".base";
my $outDir = $testId.($op eq "setTests" ? ".base" : ".test");
print " Running test '$testId', operation '$op', options '$options', 
directory '$outDir'\n";
system ("mkdir -p $outDir");
system ("rm -fr $outDir/test* $outDir/lvc*");
### Copy files
foreach my $file($glm, $ref, split(/\s+/,$systems)){
    system("cp $file $outDir");

对其进行更改,以便在print命令之后,您具有如下新行。我再次使用head命令显示文件的开头
$ head -n 63 src/hubscr/RunTests.pl
#!/usr/bin/perl -w

use strict;
my $operation = (defined($ARGV[0]) ? $ARGV[0] : "test");

sub runIt{
    my ($op, $testId, $options, $glm, $hub, $lang, $ref, $systems) = @_;
    my $baseDir = $testId.".base";
    my $outDir = $testId.($op eq "setTests" ? ".base" : ".test");

    print "   Running test '$testId', operation '$op', options '$options', directory '$outDir'\n";

    ####DWB, 2018-05-21 Getting `make check` to work####
    if ( $testId eq "test1-sastt" &&
         $operation eq "test" &&
         $options eq "-G -f rttm -F rttm -a" &&
         $outDir eq "test1-sastt.test" ) # <problem 1>
    {
        print "\n";
        print "\n#### SKIPPING ####";
        print "\nJust kidding. That breaks the make.";
        print "\nIt said: \n\n";
        print "\nUnescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/{_recursive_/_recur_{ <-- HERE _sive_/_si_ve_}_}/ at ../../md-eval/md-eval.pl line 1099, <DATA> line 12.";
        print "\nrror: MDEVAL failed";
        print "\nCommand: md-eval.pl -nafcs -c 0.25 -o  -r sastt-case1.ref.rttm.filt -s sastt-case1.sys.rttm.filt -M sastt-case1.sys.rttm.filt.mdeval.spkrmap 1> sastt-case1.sys.rttm.filt.mdeval at ../hubscr.pl line 679.";
        print "\nError: Execution failed at ./RunTests.pl line 30.\n\n";
        print "\n"
        print "\nThat's a perl legacy problem, see:"
        print "\n[https://unix.stackexchange.com/a/375505/291375][1]"
        print "\nI'm outta here.";
        print "\n   Sincerely, bballdave025";
        print "\n";
        print "\n";

        return;

    }#endof:  if (<problem 1>)

    if ( $testId eq "test2-sastt" &&
         $operation eq "test" &&
         $options eq "-G -f rttm -F rttm -a" &&
         $outDir eq "test2-sastt.test" ) # <problem 2>
    {
        print "\n";
        print "\n#### SKIPPING ####";
        print "\nJust kidding. That breaks the make.";
        print "\nIt said: \n\n";
        print "\nError: Test test2-sastt has failed.  Diff output is :";
        print "\ndiff -i -x CVS -x .DS_Store -x log -x '*lur' -I '[cC]reation[ _]date' -I md-eval -r test2-sastt.test/sastt-case2.sys.rttm.filt.alignments/segmentgroup-116.html test2-sastt.base/sastt-case2.sys.rttm.filt.alignments/segmentgroup-116.html";
        print "\n 45c45";
        print "\n < jg.drawStringRect(\"SUB48\",0, 47, scale*656, \"left\");";
        print "\n ---";
        print "\n####  and a whole bunch of other draw stuff! ####";
        print "\n1 at ./RunTests.pl line 61.\n\n";
        print "\n"
        print "\nThat looks like Java drawing code, and I don't"
        print "\neven want to mess with it!"
        print "\nI'm outta here.";
        print "\n   Sincerely, bballdave025";
        print "\n";
        print "\n";

        return;

    }#endof:  if (<problem 2>)

    system ("mkdir -p $outDir")

现在您应该能够通过。尝试一下:
make check

关于c++ - sclite(SCTK) `make check`故障,C++/perl/Cygwin,可以安全使用Perl4的东西吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50283077/

相关文章:

oracle - 如何在 Perl 脚本中访问 shell 环境变量

regex - 使用正则表达式创建子集

c - 用 C 语言编写 Makefile

c++ - Visual Studio 2013 将 EXEC 前缀添加到 makefile 输出

c++ - 我需要 MFC 自动创建的 CShellManager 吗?

c++ - 深度图像上的表面法线

c++ - 如何理解 C++ 函数中的返回引用?

perl - 在 Perl 中使用 map 仅在键存在时进行映射

使用外部库将 Make 转换为 CMake

c++ - 语法错误 : identifier not found. .. 但我已经包含了它? C++