I am trying to build a golang program which uses a static lib (.a file)
the directory struct for my project as below
└─testserver ├─bin ├─pkg └─src ├─logging └─testserver ├─libtest.a └─test.go
the flags for cgo in test.go as below
// #cgo LDFLAGS: -L /home/test/testserver/src/testserver -ltest // #include "test.h" import "C"
when I am using absolute path for LDFLAGS -L, it works fines, but when I change the path to a relative path, eg
// #cgo LDFLAGS: -L ./testserver -ltest
and then run the command
go install testserver
it returns an error to me, and says "cannot find -ltest"
my question is how can I use a relative path in LDFLAGS ? , so that I can build the project in any path.