英文:
Error encountered running simple cgo file
问题
我正在尝试测试cgo代码。
package main
// #include <stdlib.h>
import (
"C"
"fmt"
)
func main() {
fmt.Printf("test %d\n", int(C.random()))
}
请检查最后的错误。出了什么问题?
英文:
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?
答案1
得分: 1
这个程序的输出是什么?
package main
/*
#include <stdlib.h>
*/
import "C"
import (
"fmt"
)
func main() {
fmt.Printf("test %d\n", int(C.rand()))
}
英文:
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()))
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论