在 Go 中結(jié)束 OpenJtalk,文件被成功包含并且類型被引用沒有問題,但函數(shù)會觸發(fā)undefined reference錯誤。jtalk.go:package main// #cgo CFLAGS: -I/home/vagrant/open_jtalk/njd [...etc]/*#include <stdio.h>#include <stdlib.h>#include <stdarg.h>#include <string.h>#include <math.h>// Main headers #include "mecab.h"#include "njd.h"#include "jpcommon.h"#include "HTS_engine.h"// Sub headers #include "text2mecab.h"#include "mecab2njd.h"#include "njd_set_pronunciation.h"#include "njd_set_digit.h"#include "njd_set_accent_phrase.h"#include "njd_set_accent_type.h"#include "njd_set_unvoiced_vowel.h"#include "njd_set_long_vowel.h"#include "njd2jpcommon.h"*/import "C"type Open_JTalk struct { mecab C.Mecab each of these struct references are fine njd C.NJD jpcommon C.JPCommon engine C.HTS_Engine }func (open_jtalk *Open_JTalk) Open_JTalk_initialize() { C.Mecab_initialize(&open_jtalk.mecab) // when any function is called the error happens C.NJD_initialize(&open_jtalk.njd) C.JPCommon_initialize(&open_jtalk.jpcommon) C.HTS_Engine_initialize(&open_jtalk.engine)}func main() {}奇怪的是,這些相同的函數(shù)是在類型之后聲明的:mecab.h// line 1584typedef struct _Mecab{ char **feature; int size; mecab_t *mecab;} Mecab;BOOL Mecab_initialize(Mecab *m);項目網(wǎng)頁:http : //open-jtalk.sourceforge.net/
包含文件中的 CGO 未定義引用
拉風(fēng)的咖菲貓
2021-09-27 16:44:46