In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
How to carry out golang cross-compilation, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
1. Comparison table of environmental variables
Golang cross-compilation environment variables comparison table
GOOS | GOARCH | OS VERSION-- |-- linux | 386 / amd64 / arm | > = Linux 2.6darwin | 386 / amd64 | OX X (Snow Leopard + Lion) freebsd | 386 / amd64 | > = FreeBSD 7 windows | 386 / amd64 | > = Windows 20002, using 2.1Windows
Compiling Mac 64-bit executable programs under Windows
Set CGO_ENABLED=0set GOOS=darwinset GOARCH=amd64go build main.go
Compiling Linux 64-bit executable programs under Windows
Set CGO_ENABLED=0set GOOS=linuxset GOARCH=amd64go build main.go2.2 linux
Compiling Mac 64-bit executable programs under Linux
Export CGO_ENABLED=0export GOOS=darwinexport GOARCH=amd64go build main.go
Compiling Windows 64-bit executable programs under Linux
Export CGO_ENABLED=0export GOOS=windowsexport GOARCH=amd64go build main.go2.3 Mac OS
Compiling Windows 64-bit executable programs under Mac
Export CGO_ENABLED=0export GOOS=windowsexport GOARCH=amd64go build main.go
Compiling Linux 64-bit executable programs under Mac
Export CGO_ENABLED=0export GOOS=linuxexport GOARCH=amd64go build main.go3, Note 3.1 CGO_ENABLED explanation
By default, Go's runtime environment variable CGO_ENABLED=1, which starts cgo by default, allows you to call C code in Go code
If the standard library is compiled in CGO_ENABLED=1, the final binaries may be dynamically linked, so it is recommended that you set CGO_ENABLED=0 to avoid unnecessary problems in the migration process.
After reading the above, have you mastered how to cross-compile golang? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.