Reputation: 3308
I'm trying to test cgo code.
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
please check the last error. what's wrong?
Upvotes: 2
Views: 1100
Reputation: 166539
What output do you get from this program?
package main
/*
#include <stdlib.h>
*/
import "C"
import (
"fmt"
)
func main() {
fmt.Printf("test %d\n", int(C.rand()))
}
Upvotes: 1