Can not use Azure Speech golang SDK on Macos

34 Views Asked by At

When I followed the official guide to use Azure Speech SDK golang , I am getting Undefined symbols for architecture x86_64 error. Changed the architecture value etc but it didn't work.

 /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
1

There are 1 best solutions below

0
Onur Yıldırım On BEST ANSWER

I found these instructions in an issue under the cognitive-services-speech-sdk-go repo, I finally figured out that Azure guidelines are not updated correctly for MacOS.

Install Speech SDK to your 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"

Setup compiler and linker flags for 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"

After this you should be able to use Azure Speech SDK golang in your project.

Source