Closed xcshuan closed 5 years ago
If there are a shared library and a static library having the same name in the same directory, then the shared library is linked. So one way to link static library is as the followings:
env CGO_LDFLAGS="-lmclbn384_256 -lmcl -lstdc++ -lgmp -lgmpxx -lcrypto" go build -tags bn384_256 aaa.go
cat aaa.go
package main
import (
"fmt"
"github.com/herumi/mcl/ffi/go/mcl"
)
func main() {
mcl.Init(mcl.BLS12_381)
var a mcl.Fr
a.SetString("256", 10)
fmt.Printf("a=%s\n", a.GetString(16))
}
@herumi Thanks.... I have tested your library in our project, it works well.
I want to use the library in a golang project use cgo, first, I use "sudo make install" and the libraries install in "/usr/local", but "/usr/local/lib" has only "libmcl.a" and "libmcl.so", and I move "libmclbn384.a" and "libmclbn384.so" from "mcl/lib" to "/usr/local/lib" and the go code works well.
but if I want to use pure static library(copy the .a and .h to golang project), How should I do? I think I should change all the header file about path, and specify the link path where the static library locate. I try to do that, but don't work. Is there some idea to do that? I'm not familiar with C++.