cgo如何使go调用不通系统的库?

JGbooks · · 747 次点击
https://golang.google.cn/pkg/go/build/#hdr-Build_Constraints http://blog.ralch.com/tutorial/golang-conditional-compilation/
#1
更多评论
https://groups.google.com/forum/#!topic/Golang-Nuts/MwTQVXly9wo https://github.com/draffensperger/go-interlang/blob/master/go_to_c/dynamic_c_lib/lp.go #cgo windows LDFLAGS: -lwindows #cgo linux LDFLAGS: -llinux
#2
https://golang.google.cn/cmd/cgo/#hdr-Using_cgo_with_the_go_command CFLAGS, CPPFLAGS, CXXFLAGS, FFLAGS and LDFLAGS may be defined with pseudo #cgo directives within these comments to tweak the behavior of the C, C++ or Fortran compiler. Values defined in multiple directives are concatenated together. The directive can include a list of build constraints limiting its effect to systems satisfying one of the constraints (see https://golang.google.cn/pkg/go/build/#hdr-Build_Constraints for details about the constraint syntax). For example: // #cgo CFLAGS: -DPNG_DEBUG=1 // #cgo amd64 386 CFLAGS: -DX86=1 // #cgo LDFLAGS: -lpng // #include <png.h> import "C" `// +build`的约束条件同样适用于`// #cgo`
#3