c++ - sclite (SCTK),C++ 模板参数 Filter::Filter* 无效。 Cygwin

标签 c++ c templates makefile header-files

问题

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

通过执行 64 位编译,我能够解决 file [format] not recognized 的问题,如 README 末尾所述并在 another 中详细解释我的 SO 帖子。

现在,我再次关注installation instructions并在键入 make all

后得到以下错误
In file included from main.cpp:20:0:
recording.h:122:36: error: template argument 2 is invalid
         map<string, Filter::Filter*> filters;
                                    ^
recording.h:122:36: error: template argument 4 is invalid
make[3]: *** [makefile:59: main.o] Error 1
make[3]: Leaving directory 
'/cygdrive/c/Me/programs/nist/sctk/src/asclite/core'
make[2]: *** [makefile:12: all] Error 2
make[2]: Leaving directory 
'/cygdrive/c/Me/programs/nist/sctk/src/asclite'
make[1]: *** [makefile:12: all] Error 2
make[1]: Leaving directory '/cygdrive/c/Me/programs/nist/sctk/src'
make: *** [makefile:20: all] Error 2

有人知道我可以做什么来完成安装吗?

注意:回答此处的问题后,实际上并未在 Cygwin 上完成安装。有事可做beforeafter ,我将在 SO 上发布我的进展以及关于下一步要去哪里的问题。


我的尝试

我没有在 C++ 文档中找到任何关于 Filter 的信息,并且搜索了克隆目录中的文件 ( $ find . -type f\( -name "*.h "-o -name "*.c"-o -name "*.cpp"\) -print0 | xargs -I'{}' -0 grep -Hn "Filter"{} ) 部分给出:

./src/asclite/core/checker.h:26:class Checker : public Filter
./src/asclite/core/filter.cpp:19: * Abstract interface to a Filter.
./src/asclite/core/filter.cpp:25:Filter::Filter()
./src/asclite/core/filter.cpp:30:Filter::~Filter()
./src/asclite/core/filter.h:26: * Abstract interface to a Filter.
./src/asclite/core/filter.h:28:class Filter
./src/asclite/core/filter.h:32:         Filter();
./src/asclite/core/filter.h:34:         virtual ~Filter();

...

据我所知,这意味着在命名空间 Filter 中有一个构造函数 Filter

这是filter.cpp的“代码部分”

$ cat src/asclite/core/filter.cpp | tail -16

/**
 * Abstract interface to a Filter.
 */

#include "filter.h" // class's header file

// class constructor
Filter::Filter()
{
}

// class destructor
Filter::~Filter()
{
}

这是filter.h

的代码部分
$ cat src/asclite/core/filter.h | tail -27

#ifndef FILTER_H
#define FILTER_H

#include "stdinc.h"
#include "speech.h"
#include "speechset.h"

/**
 * Abstract interface to a Filter.
 */
class Filter
{
        public:
                // class constructor
                Filter();
                // class destructor
                virtual ~Filter();

                virtual bool isProcessAllSpeechSet() = 0;
                virtual unsigned long int ProcessSingleSpeech(Speech* speech) = 0;
                virtual unsigned long int ProcessSpeechSet(SpeechSet* ref, map<string, SpeechSet*> &hyp) = 0;

                virtual void LoadFile(const string& filename) = 0;
};

#endif // FILTER_H

系统详情

$ 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

最佳答案

我的答案

(另请查看我在问题下的评论,描述了 kaldi 解决方案。)

注意:这个问题解决后又出现了一个问题。请参阅此答案的底部以获得帮助。

我一直在研究这个问题,我发现答案最终是改变了有问题的行(和其他一些行),正如我将要展示的那样。提醒一下,有问题的行来自文件 src/asclite/core/recording.h

recording.h:122:28: error: template argument 2 is invalid
         map<string, Filter::Filter*> filters;

我改成了

map<string, ::Filter*> filters;

我也在 Filter::Filter* 中做了相同的更改( ::Filter*src/asclite/core/recording.cpp ) ,第 157 和 164 行,结果为:

157: map<string, ::Filter*>::iterator fi, fe;

164: ::Filter* ptr_elt = fi->second;

在寻找答案和解释时,我还找到了another page有解决方案,但没有解释。

下面的解释中有一个“让我澄清一下”的注释,说明这只是安装的部分解决方案。


研究和(希望)解释

我首先注意到有问题的行前后的声明没有 namespace 和双冒号,而我们的行有 Filter::Filter* ,如下所示:

$ cat src/asclite/core/recording.h |头-n 130 |尾-24 map 对齐器;

        /**
         * contain all the available Scorer
         */
        map<string, Scorer*> scorer;

        /**
         * contain all the available Segmentors
         */
        map<string, Segmentor*> segmentors;

        /**
                 * contain all the available Filters
         */
        map<string, Filter::Filter*> filters;

                /**
                 * Database for the optimization speaker alignment
                 */
                SpeakerMatch* m_pSpeakerMatch;

                /** the logger */
        static Logger* logger;

我首先尝试删除 Filter命名空间和两个冒号 ( :: )。我发现了一些网站( 123 ……),其中似乎没有 namespace 和头文件中双冒号的示例。它们只在实现文件中。我删除了 Filter:: (来自有问题的行和 recording.cpp 中的其他一些行),但这给了我

In file included from main.cpp:20:0:
recording.h:122:28: error: template argument 2 is invalid
         map<string, Filter*> filters;
                            ^
recording.h:122:28: error: template argument 4 is invalid

在研究了双引号运算符(例如 here )之后,在其他解决方案的帮助下,我更改了所有 Filter::Filter*::Filter .

编译时出现了一些警告,但安装过程的其余部分正常运行让我澄清一下 make configmake all零件工作。 make test 中有错误部分,在此处的另一个问题中详细说明(待问)。但是,运行 make install创建我需要的可执行文件。

有关前置双冒号的信息,我从 another SO post 获得了一些帮助.构造函数前的两个冒号让我们知道它在全局范围内,即在 recording.h/.cpp 之外。这是必要的,因为在 recording.h/.cpp , 还有一个 Filter Recording 的方法创建的对象。 (随着我的写作,事情变得越来越清晰。)

$ cat src/asclite/core/recording.cpp | head -n 290 | tail -5
/**
 * Filter the references and hypothesis with the availables filters.
 */
void Recording::Filter(const vector<string> & _filters)
{

$ cat src/asclite/core/recording.h | head -n 75 | tail -4
        /**
         * Filter the references and hypothesis with the availables filters.
         */
        void Filter(const vector<string> & _filters);

我认为我们没有命名空间的原因(即在 Filter 之前没有 ::)解释为 here on SO .在这篇文章中,.cpp(实现)文件中的构造函数代码给出了解释:

Mems::Mems() //you don't actually need to use the class keyword in your .cpp file; 
just the class name, the double colon, and the method name is enough to mark this 
as a class method

据我了解,将 Filter::FilterRecording 的代码中对象会建议 Filter::FilterRecording 的类方法对象,但这没有意义,因为第一个 Filter在冒号之前显然将其标记为 Filter 的类方法目的。

如果此解释有误或不清楚,请随时修改。

此解决方案解决了问题中的问题,但有 more to do在安装检查成功之前。

关于c++ - sclite (SCTK),C++ 模板参数 Filter::Filter* 无效。 Cygwin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50243691/

相关文章:

c++ - vector 调整大小奇怪的行为

C++ 转换模板

c++ - 检测容器是否具有迭代器类型

c - 在打印链接列表的状态时程序进入无限循环

c - 访问结构中的结构指针时出现段错误

"short"的 C 数值常量后缀

c++ - 在 C++ 的另一个类中使用模板类

c++ - 通过 Derived::f2() 调用 f1() 时调用了谁的函数?

c++ - nullptr 的运算符 <<(流输出)

c++ - 如何将文件夹设置为 Xcode 中的全局包含,类似于 Visual Studio?