我目前正在尝试安装NIST的sclite
,它是SCTK 2.4.0的一部分(github或newer version)。我正在尝试在Cygwin
中的bash
上安装。使用make
完成安装。
我已经跳过了安装的make configure
和make 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个部分特别相关,我将链接这些部分(first,second和third)。我将在这里插入零件:
def_art.pl
is looking forgetopts.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: modernperl
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.pl
和Perl4::CoreLibs
。我在本网站上引用了用于wget
的URL。显然,在其他*NIX
发行版中,可以使用软件包管理器,例如apt-get install libperl4-corelibs-perl
要么
yum install perl-Perl4-CoreLibs
但是我找不到通过
apt-cyg
进行的安装。如“我正在做什么”部分中所述,我能够从tarball安装它们。再说一次我的主要问题:这是安全/良好的编程习惯吗?有更好的解决方案吗?
如果有更好的解决方案(使用Perl 5),似乎this link可能会引导它。
其他可能相关的链接:有关
flush.pl
的link_{n}和link{n+1},有关getopts.pl
和Perl4::CoreLibs
的link_{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 clean
,make config
,make all
和make 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/
请注意,目录中现在也有
html
和htm
文件,它们也提供了文档。通过`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/