Import '.so' library in Go

I’m trying to import .so library in Go project like this:

// #cgo LDFLAGS: -L. -libcapi20.so
import "C"

I get this error:

/usr/bin/ld: cannot find -libcapi20.so
collect2: error: ld returned 1 exit status

I tried to put libcapi20.so in different folders. Even in usr/bin. Tried to write path to .so-file in “-L.” flag. Tried without “.so” suffix. Same error everytime.

My OS: Ubuntu 17.10. Go SDK: 1.10, actually in 1.9 - same error.

If I am importing library correct then I suppose it can be incorrect version of Ubuntu or broken .so-file.

This should read:

// #cgo LDFLAGS: -L. -lcapi20
import "C"
2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.