mac 上golang编译 安卓系统的so 错误 'android/log.h' file not found

lib.go

package main

import "C"


//export SpeedTest
func SpeedTest(config *C.char) {
	configContent := C.GoString(config)

	run(configContent)
}

func main() {

}
  1. 需要安装NDK,用 Android studio安装,在SDK Maneger的SDK Tool里选择安装NDK(side by side),成功后一般在~/Library/Android/sdk/ndk/27.0.12077973
  2. 在ndk目录下执行 python $NDK/build/tools/make_standalone_toolchain.py
    --arch arm64 --api 35 --install-dir toolchain [https://github.com/golang/go/issues/20755]
  3. CC=$NDK/toolchain/bin/clang CXX=$NDK/toolchain/bin/clang CGO_ENABLED=1 GOOS=android GOARCH=arm64 go build -buildmode=c-shared -o lib.so lib.go
posted @ 2024-09-04 17:37  screte  阅读(49)  评论(0编辑  收藏  举报