yanyiwu/gojieba

collect2.exe: error: ld returned 1 exit status

Opened this issue · 1 comments

错误:

PS D:\go\demo> go run .\jieba.go
# command-line-arguments
D:\dev\go19\pkg\tool\windows_amd64\link.exe: running g++ failed: exit status 1
D:/dev/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\tom\AppData\Local\Temp\go-link-3644197169\000008.o: in function _cgo_preinit_init': \\_\_\runtime\cgo/gcc_libinit_windows.c:40:(.text+0x37): undefined reference to __imp___iob_func'
D:/dev/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\tom\AppData\Local\Temp\go-link-3644197169\000008.o: in function x_cgo_notify_runtime_init_done': \\_\_\runtime\cgo/gcc_libinit_windows.c:105:(.text+0x1d5): undefined reference to __imp___iob_func'
D:/dev/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\tom\AppData\Local\Temp\go-link-3644197169\000008.o: in function _cgo_beginthread': \\_\_\runtime\cgo/gcc_libinit_windows.c:149:(.text+0x29e): undefined reference to __imp___iob_func'
D:/dev/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\tom\AppData\Local\Temp\go-link-3644197169\000009.o: in function x_cgo_thread_start': \\_\_\runtime\cgo/gcc_util.c:18:(.text+0x3c): undefined reference to __imp___iob_func'
collect2.exe: error: ld returned 1 exit status

代码:

package main

import (
	"fmt"
	"github.com/yanyiwu/gojieba"
	"strings"
)

func main() {
	var s string
	var words []string
	use_hmm := true
	x := gojieba.NewJieba()
	defer x.Free()

	s = "我来到北京清华大学"
	words = x.CutAll(s)
	fmt.Println(s)
	fmt.Println("全模式:", strings.Join(words, "/"))

	words = x.Cut(s, use_hmm)
	fmt.Println(s)
	fmt.Println("精确模式:", strings.Join(words, "/"))
	s = "比特币"
	words = x.Cut(s, use_hmm)
	fmt.Println(s)
	fmt.Println("精确模式:", strings.Join(words, "/"))
}

https://github.com/yanyiwu/gojieba-demo 试试这个能否成功?