配置 RHEL/CentOS 7

注意

本文引用了 CentOS,这是一个接近生命周期结束 (EOL) 状态的 Linux 发行版。 请相应地考虑你的使用和规划。 有关详细信息,请参阅 CentOS 生命周期结束指南

若要在 Red Hat Enterprise Linux (RHEL) 7 x64 和 CentOS 7 x64 上使用语音 SDK,请更新系统上的 C++ 编译器(用于 C++ 开发)和共享 C++ 运行时库。

安装依赖项

首先安装所有常规依赖项:

sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm

# Install development tools and libraries
sudo yum update -y
sudo yum groupinstall -y "Development tools"
sudo yum install -y alsa-lib dotnet-sdk-2.1 java-1.8.0-openjdk-devel openssl
sudo yum install -y gstreamer1 gstreamer1-plugins-base gstreamer1-plugins-good gstreamer1-plugins-bad-free gstreamer1-plugins-ugly-free

C/C++ 编译器和运行时库

使用此命令安装必备组件包:

sudo yum install -y gmp-devel mpfr-devel libmpc-devel

接下来,更新编译器和运行时库:

# Build GCC 7.5.0 and runtimes and install them under /usr/local
curl https://ftp.gnu.org/gnu/gcc/gcc-7.5.0/gcc-7.5.0.tar.gz -O
tar -xf gcc-7.5.0.tar.gz
mkdir gcc-7.5.0-build && cd gcc-7.5.0-build
../gcc-7.5.0/configure --enable-languages=c,c++ --disable-bootstrap --disable-multilib --prefix=/usr/local
make -j$(nproc)
sudo make install-strip

如果需要将更新的编译器和库部署在多台计算机上,则可以将它们从 /usr/local 下复制到其他计算机上。 如果只需要运行时库,则 /usr/local/lib64 中的文件已足够。

环境设置

运行以下命令来完成配置:

# Add updated C/C++ runtimes to the library path
# (this is required for any development/testing with Speech SDK)
export LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH

# For C++ development only:
# - add the updated compiler to PATH
#   (note, /usr/local/bin should be already first in PATH on vanilla systems)
# - add Speech SDK libraries from the Linux tar package to LD_LIBRARY_PATH
#   (note, use the actual path to extracted files!)
export PATH=/usr/local/bin:$PATH
hash -r # reset cached paths in the current shell session just in case
export LD_LIBRARY_PATH=/path/to/extracted/SpeechSDK-Linux-<version>/lib/centos7-x64:$LD_LIBRARY_PATH

注意

Linux .tar 包包含 RHEL/CentOS 7 的专用库。 这些库包含在 lib/centos7-x64 中,如上面 LD_LIBRARY_PATH 的环境设置示例所示。 lib/x64 中的语音 SDK 库适用于所有其他受支持的 Linux x64 分发版(包括 RHEL/CentOS 8),不适用于 RHEL/CentOS 7。

后续步骤