我试图测试cgo代码。
package main
// #include <stdlib.h>
import (
"C"
"fmt"
)
func main() {
fmt.Printf("test %d\n", int(C.random()))
}
D:\Dev\Go\src>go version
go version go1.3 windows/amd64
D:\Dev\Go\src>go env
set GOARCH=amd64
set GOBIN=
set GOCHAR=6
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\\Dev\\Go
set GORACE=
set GOROOT=c:\go
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64-mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
D:\Dev\Go\src>go run test_binding.go
# runtime/cgo C:\Users\hyoon\AppData\Local\Temp\go-build779392087\runtime\cgo\_obj\_cgo_defun.c:7 6c: No such file or directory: runtime.h
请检查上一个错误。什么错了?
答案 0 :(得分:1)
你从这个程序得到什么输出?
package main
/*
#include <stdlib.h>
*/
import "C"
import (
"fmt"
)
func main() {
fmt.Printf("test %d\n", int(C.rand()))
}