go build instead of
go build somefile.go does it. So obvious now …
难道不是“去获取”只是获取文件，然后cgo +“去构建”它们吗？ 显然不是
I have a problem building a fairly simple local CGO project. Consider this very small CGO package of just 3 files (glut.go, support.c and support.h file) -- if I just go get it, these files are downloaded to
then some secret magic happens and go get builds the following output file:
However, if I copy the three source files to \mytmp, cd into \mytmp and go build -o glut.a glut.go, I get some 40-60 error messages like this one:
C:\Usersoxor\AppData\Local\Temp\go-build191975110\command-line-arguments\_obj\glut.cgo2.o: In function `_cgo_b46885fb7c57_Cfunc_goCreateMenu': ./glut.go:195: undefined reference to `goCreateMenu'
If I run go get with the -x command-line argument, I can see that support.c is picked up during the build process and given to gcc:
gcc -I . -g -O2 -m64 -mthreads -I $WORK\github.com\zombiezen\Go-GLUT\glut\_obj\ -o $WORK\github.com\zombiezen\Go-GLUT\glut\_obj\support.o -c .\support.c
However, with go build -x, this is not the case, support.c is skipped. Why? How do I call go build to work exactly like go get does?
- 难道不是“去获取”只是获取文件，然后cgo +“去构建”它们吗？ 显然不是