ziutek / ftdi

Go binding for libFTDI
Other
25 stars 14 forks source link

Fix build as static library #15

Open rasky opened 3 years ago

rasky commented 3 years ago

To build ftdi as part of a static binary, there is a fix required. The line #cgo pkg-config: libftdi1 in device.go must be changed to #cgo pkg-config: --static libftdi1. This tells go build to invoke pkg-config with the --static argument to provide the correct library list for the static linking case.

This is a known shortcoming of Go, documented in https://github.com/golang/go/issues/26492. The same issue (in the description) reports an example of a common workaround: using two Go files to switch the different pkg-config invocation, guarded by the static_build build tag which seems to be the de-facto standard.

ziutek commented 3 years ago

Can you make a pull request with changes that will add support for static_build tag?