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.
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 tellsgo build
to invokepkg-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 thestatic_build
build tag which seems to be the de-facto standard.