go version devel +b32ab1e2e6df Fri Apr 05 21:24:07 2013 +0200 linux/amd64
Install some package that uses cgo with something like this in it:
#cgo pkg-config: some_c_library
The package will install without error.
Next, try to build a Go program that imports that package. It will fail with 'undefined
reference' errors.
Build the program with -ldflags="-linkmode internal" and it builds without
error, and works fine.
Remove the pkg-config directive from the package, replace it with this:
#cgo CFLAGS: -I/path/to/some_c_library/header/files
#cgo LDFLAGS: -L/path/to/some_c_library/library/files -lsome_c_library
Then install it, and then, programs importing the package can be build in the normal
way, without having to add the -ldflags option.