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