记录在macOS上编译Windows和Linux的go程序,带CGO调用C代码,比如go-sqlite3包,已测试通过。

参考链接:

1. Windows平台(mingw-w64)

> 安装编译器:brew install mingw-w64

> 编译指令:CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc go build -v

2. Linux平台(x86_64-linux-musl-gcc)

> 安装编译器:brew install FiloSottile/musl-cross/musl-cross

>编译指令:CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-musl-gcc CGO_LDFLAGS="-static" go build -a -v

-a:重新编译

-static表示静态连接,没有这个选项,linux上运行报:-bash: ./xxx: /lib/ld-musl-x86_64.so.1: bad ELF interpreter: No such file or directory

{"data":{"id":"8000-000000437045-0","name":"SEO专题页栏目分发组","type":"1","position":"8000-000000004003-0","status":1,"linkList":[{"id":"8000-000000668559-0","keyword":"3步对手机实时视频流做AI分析","url":"https://bbs.huaweicloud.com/forum/thread-75165-1-1.html","secondDomain":null,"keyTitle":null,"weight":0,"tag":null,"pageTitle":null,"inputType":null,"updateByName":"pWX619094","updateByAccount":"pWX619094","updateAt":"2020-11-18 22:22:05","createByName":"pWX619094","createByAccount":"pWX619094","createAt":"2020-11-18 22:22:05","contentCheckCode":0},{"id":"8000-000000657112-0","keyword":"关于AR502H的RS485接口的使用","url":"https://bbs.huaweicloud.com/forum/thread-59430-1-1.html","secondDomain":null,"keyTitle":null,"weight":0,"tag":null,"pageTitle":null,"inputType":null,"updateByName":"pWX619094","updateByAccount":"pWX619094","updateAt":"2020-11-18 22:03:05","createByName":"pWX619094","createByAccount":"pWX619094","createAt":"2020-11-18 22:03:05","contentCheckCode":0},{"id":"8000-000000637533-0","keyword":"[即插即用PLC]组网上线的尾端IP与mqtt发布出来的IP地址不一致?","url":"https://bbs.huaweicloud.com/forum/thread-22780-1-1.html","secondDomain":null,"keyTitle":null,"weight":0,"tag":null,"pageTitle":null,"inputType":null,"updateByName":"pWX619094","updateByAccount":"pWX619094","updateAt":"2020-11-18 21:35:12","createByName":"pWX619094","createByAccount":"pWX619094","createAt":"2020-11-18 21:35:12","contentCheckCode":0},{"id":"8000-000000616147-0","keyword":"功能描述","url":"https://support.huaweicloud.com/odevg-A800_3000_3010/atlaste_10_0344.html","secondDomain":null,"keyTitle":null,"weight":0,"tag":null,"pageTitle":null,"inputType":null,"updateByName":"pWX619094","updateByAccount":"pWX619094","updateAt":"2020-11-18 21:08:09","createByName":"pWX619094","createByAccount":"pWX619094","createAt":"2020-11-18 21:08:09","contentCheckCode":0},{"id":"8000-000000599545-0","keyword":"轮播列表柱状图","url":"https://support.huaweicloud.com/usermanual-dlv/dlv_01_0854.html","secondDomain":null,"keyTitle":null,"weight":0,"tag":null,"pageTitle":null,"inputType":null,"updateByName":"pWX619094","updateByAccount":"pWX619094","updateAt":"2020-11-18 21:00:40","createByName":"pWX619094","createByAccount":"pWX619094","createAt":"2020-11-18 21:00:40","contentCheckCode":0},{"id":"8000-000000582013-0","keyword":"CGS权限及授权项","url":"https://support.huaweicloud.com/usermanual-cgs/cgs_01_0057.html","secondDomain":null,"keyTitle":null,"weight":0,"tag":null,"pageTitle":null,"inputType":null,"updateByName":"pWX619094","updateByAccount":"pWX619094","updateAt":"2020-11-18 20:52:50","createByName":"pWX619094","createByAccount":"pWX619094","createAt":"2020-11-18 20:52:50","contentCheckCode":0},{"id":"8000-000000546389-0","keyword":"数据湖应用解析:Spark on Elasticsearch一致性问题","url":"https://bbs.huaweicloud.com/blogs/175192","secondDomain":null,"keyTitle":null,"weight":0,"tag":null,"pageTitle":null,"inputType":null,"updateByName":"pWX619094","updateByAccount":"pWX619094","updateAt":"2020-11-18 20:01:19","createByName":"pWX619094","createByAccount":"pWX619094","createAt":"2020-11-18 20:01:19","contentCheckCode":0},{"id":"8000-000000539579-0","keyword":"素小暖讲hibernate","url":"https://bbs.huaweicloud.com/blogs/143403","secondDomain":null,"keyTitle":null,"weight":0,"tag":null,"pageTitle":null,"inputType":null,"updateByName":"pWX619094","updateByAccount":"pWX619094","updateAt":"2020-11-18 19:49:55","createByName":"pWX619094","createByAccount":"pWX619094","createAt":"2020-11-18 19:49:55","contentCheckCode":0},{"id":"8000-000000521065-0","keyword":"人民战“疫”打出全球智慧城市分水岭,华为助攻!","url":"https://bbs.huaweicloud.com/blogs/152389","secondDomain":null,"keyTitle":null,"weight":0,"tag":null,"pageTitle":null,"inputType":null,"updateByName":"pWX619094","updateByAccount":"pWX619094","updateAt":"2020-11-18 17:20:28","createByName":"pWX619094","createByAccount":"pWX619094","createAt":"2020-11-18 17:20:28","contentCheckCode":0},{"id":"8000-000000440558-0","keyword":"创建Hyper-V虚拟交换机","url":"https://support.huaweicloud.com/bestpractice-bms/bms_bp_0406.html","secondDomain":null,"keyTitle":null,"weight":0,"tag":null,"pageTitle":null,"inputType":null,"updateByName":"pWX619094","updateByAccount":"pWX619094","updateAt":"2020-11-14 18:55:28","createByName":"pWX619094","createByAccount":"pWX619094","createAt":"2020-11-14 18:55:28","contentCheckCode":0}]},"total":null,"message":"success","status":true}