当我遵循官方guide使用Azure Speech SDK golang时,我得到了 Undefined symbols for architecture x86_64错误.改变了建筑价值等,但它没有工作.

 /usr/local/Cellar/go/1.20.5/libexec/pkg/tool/darwin_amd64/link: running cc failed: exit status 1
 ld: warning: -no_pie is deprecated when targeting new OS versions
 ld: warning: ignoring file <speech-sdk-path>/lib/x86/libMicrosoft.CognitiveServices.Speech.core.so, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x7F 0x45 0x4C 0x46 0x01 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 )
 Undefined symbols for architecture x86_64:
   "_add_source_lang_config_to_auto_detect_source_lang_config", referenced from:
       __cgo_c0b4197be0b1_Cfunc_add_source_lang_config_to_auto_detect_source_lang_config in 000011.o

推荐答案

我在认知服务-语音-SDK-Go repo下发现了这instructions个问题,我终于发现Azure指南没有针对MacOS正确更新.

将Speech SDK安装到Mac

export SPEECHSDK_ROOT="/your/path"
mkdir -p "$SPEECHSDK_ROOT"
wget -O MicrosoftCognitiveServicesSpeech.xcframework.zip https://aka.ms/csspeech/macosbinary
unzip MicrosoftCognitiveServicesSpeech.xcframework.zip -d "$SPEECHSDK_ROOT"

为Go设置编译器和链接器标志

export CGO_CFLAGS="-I$SPEECHSDK_ROOT/MicrosoftCognitiveServicesSpeech.xcframework/macos-arm64_x86_64/MicrosoftCognitiveServicesSpeech.framework/Headers"
export CGO_LDFLAGS="-Wl,-rpath,$SPEECHSDK_ROOT/MicrosoftCognitiveServicesSpeech.xcframework/macos-arm64_x86_64 -F$SPEECHSDK_ROOT/MicrosoftCognitiveServicesSpeech.xcframework/macos-arm64_x86_64 -framework MicrosoftCognitiveServicesSpeech"

在此之后,您应该能够在项目中使用Azure Speech SDK golang.

Source

Go相关问答推荐

golang父进程的副本无法进行https/tls调用并获得tls:未能验证证书""

理解Golang并发:缓冲通道的意外行为

在不耗尽资源的情况下处理S3文件下载

如何在Golang中获取mp3文件的持续时间?

如何使用Gio设置标题栏图标

Go Gin:验证 base64

在 Cloud Run 中找不到默认凭据

使用 Go 根据 /etc/shadow 文件中的散列密码验证密码

GoLang:net.LookupHost 返回重复的 ips

在 .go 文件中运行一个函数和在 Go 模板中调用它有什么区别?

也许在 golang 中包(字符串和字符串类型不匹配)

动态 SQL 集 Golang

为什么互斥量比 golang 中的通道慢?

整理时转换值

Golang Gin 绑定请求正文 XML 到 Slice

在 docker kill --signal=SIGX 上以这种方式关闭容器内运行的 go 应用程序是否安全?

gorm 获取列名

golang 如何从字符串中查找表情符号?

函数的递归调用以 goroutine 和惯用方式开始,以在所有工作 goroutine 完成时继续调用者

如何使用 context.WithCancel 启动和停止每个会话的心跳?