为了安装golong + protobuf, 安装了几个prosix工具,从头编译。开发者帮助开发者
M1芯片虽然已经出来一段时间了,还是有很多工具没有很好的迁移到新的系统上来。
我发现,home brew 虽然支持 Rosetta启动,但是需要安装两个版本的home brew。两个环境的切换很麻烦,而且arm64版很多工具的管理都很差。而且涉及到两种版本二进制需要创建不同的安装路径,不容易做到版本切换。很容易混乱。所以我只好放弃不用。
对于比较好用的工具管理就是 sdkman。https://sdkman.io/ 在 sdkman 能够管理的工具我已经基本上使用 sdkman 来管理了。比如 jdk, scala, sbt, springboot, visualvm 等等。
sdkman 的配置文件有一个非常重要的选项可以强制只显示arm64本地的安装包。大家可以选择使用。
vi ~/.sdkman/etc/config
#设置只显示arm64本地化安装包
sdkman_rosetta2_compatible=false
我们以protobuf 为例,当前protobuf还没有提供aarch64的发版。x64的却是不能工作。
所以我们在很多时候还是需要自己来编译。那就说干就干吧。
- 首先需要安装 xcode 的命令行工具。
sudo xcode-select —install
如果你已经安装了,但是由于长期使用,系统有些乱,那就可以这么来一下:
sudo xcode-select —reset
2. 安装相关的posix工具
Install autoconf
CFLAGS="-arch arm64" CXXFLAGS=$CFLAGS
curl -#OL https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar xf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure
make
sudo make install
Verify autoconf
which autoconf
autoconf --version
Install Automake
CFLAGS="-arch arm64" CXXFLAGS=$CFLAGS
curl -#OL https://ftp.gnu.org/gnu/automake/automake-1.16.3.tar.gz
tar xf automake-1.16.3.tar.gz
cd automake-1.16.3
./configure
make
sudo make install
Verify Automake
which automake
automake --version
Install libtool
CFLAGS="-arch arm64" CXXFLAGS=$CFLAGS
curl -#OL https://ftp.gnu.org/gnu/libtool/libtool-2.4.2.tar.gz
tar xf libtool-2.4.2.tar.gz
cd libtool-2.4.6
./configure
make
sudo make install
Verify libtool
which libtool
libtool --version
3. 编译安装protobuf
git clone https://github.com/protocolbuffers/protobuf.git
autoreconf -i
./autogen.sh
./configure
make
make check
sudo make install
# 设置环境变量
export PATH=/opt/usr/local/bin:$PATH
4. 安装protobuf golang支持
Go语言已经支持M1所以可以按照这篇文档安装Go。
https://onexlab-io.medium.com/install-golang-apple-macos-m1-silicon-chip-87781f556b2f
结下来就可以安装protobuf工具了。
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
Update your PATH so that the protoc compiler can find the plugins:
export PATH="$PATH:$(go env GOPATH)/bin"
注意在安装中,版本有可能会有问题,请注意使用最新版本。
5. 安装AWS相关工具
安装 AWS 客户端:
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
安装kubectl :
curl -LO "https://dl.k8s.io/release/v1.21.2/bin/darwin/arm64/kubectl"
curl --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_arm64.tar.gz" -o eksctl.tgz
chmod +x kubectl
tar -xzvf eksctl.tgz
sudo mv kubectl eksctl /usr/local/bin/
参考文档: