无法使用crfsuite的C++ API编译一个非常简单的Tagger示例
Unable to compile a very simple example of Tagger with the C++ API of crfsuite
我已经从源代码(https://github.com/downloads/chokkan/crfsuite/crfsuite-0.12.tar.gz(正确安装了crfsuite。 但是当我尝试编译一个非常简单的代码时,似乎我错过了一些东西。
这是代码:
#include "crfsuite.hpp"
using namespace CRFSuite;
int main(int argc, char *argv[])
{
Tagger tagger;
}
下面是要编译的命令行:
g++ -L/usr/local/lib -I/usr/local/include -lcrfsuite tagging.cpp
和错误:
/tmp/ccIkvCFv.o: In function `CRFSuite::Trainer::Trainer()':
tagging.cpp:(.text+0x48): undefined reference to `crfsuite_data_init'
/tmp/ccIkvCFv.o: In function `CRFSuite::Trainer::init()':
tagging.cpp:(.text+0x149): undefined reference to `crfsuite_create_instance'
tagging.cpp:(.text+0x1b7): undefined reference to `crfsuite_create_instance'
/tmp/ccIkvCFv.o: In function `CRFSuite::Trainer::clear()':
tagging.cpp:(.text+0x2dd): undefined reference to `crfsuite_data_finish'
tagging.cpp:(.text+0x2ed): undefined reference to `crfsuite_data_init'
/tmp/ccIkvCFv.o: In function `CRFSuite::Trainer::append(std::vector<std::vector<CRFSuite::Attribute, std::allocator<CRFSuite::Attribute> >, std::allocator<std::vector<CRFSuite::Attribute, std::allocator<CRFSuite::Attribute> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, int)':
tagging.cpp:(.text+0x495): undefined reference to `crfsuite_instance_init_n'
tagging.cpp:(.text+0x51f): undefined reference to `crfsuite_item_init_n'
tagging.cpp:(.text+0x69b): undefined reference to `crfsuite_data_append'
tagging.cpp:(.text+0x6aa): undefined reference to `crfsuite_instance_finish'
/tmp/ccIkvCFv.o: In function `CRFSuite::Trainer::select(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
tagging.cpp:(.text+0x7e9): undefined reference to `crfsuite_create_instance'
/tmp/ccIkvCFv.o: In function `CRFSuite::Tagger::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
tagging.cpp:(.text+0x11a0): undefined reference to `crfsuite_create_instance_from_file'
/tmp/ccIkvCFv.o: In function `CRFSuite::Tagger::set(std::vector<std::vector<CRFSuite::Attribute, std::allocator<CRFSuite::Attribute> >, std::allocator<std::vector<CRFSuite::Attribute, std::allocator<CRFSuite::Attribute> > > > const&)':
tagging.cpp:(.text+0x16c6): undefined reference to `crfsuite_instance_init_n'
tagging.cpp:(.text+0x1731): undefined reference to `crfsuite_item_init'
tagging.cpp:(.text+0x17e1): undefined reference to `crfsuite_attribute_set'
tagging.cpp:(.text+0x17f4): undefined reference to `crfsuite_item_append_attribute'
tagging.cpp:(.text+0x1854): undefined reference to `crfsuite_instance_finish'
tagging.cpp:(.text+0x18ac): undefined reference to `crfsuite_instance_finish'
collect2: error: ld returned 1 exit status
路径正确(/usr/local/lib
,/usr/local/include
(
参数的顺序很重要。该库应该在您的 cpp 文件之后:
g++ -L/usr/local/lib -I/usr/local/include tagging.cpp -lcrfsuite
有关更多信息,请参阅答案为什么库的链接顺序有时会导致 GCC 中的错误?
相关文章:
- 我从int x[3]得到的一个非常奇怪的输出;
- 一个非常简单的win32套接字代码,但工作错误
- 超过CPU时间限制:当MPI_Sent一个非常大的int*时
- 无法使用crfsuite的C++ API编译一个非常简单的Tagger示例
- C++中一个非常简单的枚举类错误
- 我在内存泄漏和字符串方面遇到了一个非常奇怪的问题
- 我正在写一个非常简单的字母评分系统,if语句是最有效的吗?
- 我刚刚创建了一个非常快速的素数排序方法.如何改进?
- 在64位系统上创建一个非常大的数组的缺点是什么
- (c++)代码中一个非常奇怪的问题
- 打印出一个非常小的浮点数
- C++:C字符串、指针和一个非常有趣的while循环
- 在 matlab 中编写一个非常基本的 mex 函数
- 在C 中编写一个非常简单的事件类
- 如何取一个非常大的数的根
- 在使用Qt Creator创建一个非常简单的项目时,在Qt中遇到"segmentation fault"
- 使用C++计算一个非常大的幂
- 一个非常弱的引用(无法转换为共享)
- 在一个非常简单的程序中检测到内存泄漏.怎么办
- 非虚拟接口?(需要一个非常高性能的低级抽象)