title: go + cgo and linking
body: <p>i want to use the following c as Go's cgo:</p>
  
  <pre><code>#include &lt;X11/extensions/scrnsaver.h&gt;
  
  main() {
    XScreenSaverInfo *info = XScreenSaverAllocInfo();
    Display *display = XOpenDisplay(0);
  
    XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
    printf("%u ms\n", info-&gt;idle);
  }
  </code></pre>
  
  <p>build with:</p>
  
  <pre><code>gcc -o idle printXIdleTime.c -lX11 -lXss
  </code></pre>
  
  <p>i re-wrote that code for Go's cgo:</p>
  
  <pre><code>package tools
  
  // #cgo pkg-config: x11
  // #include &lt;X11/extensions/scrnsaver.h&gt;
  import "C"
  
  func GetIdleTime() (idleTime uint32) {
      var info *C.XScreenSaverInfo
      var display *C.Display 
  
      info = C.XScreenSaverAllocInfo()
      display = C.XOpenDisplay(0)
  
      defaultRootWindow := C.XDefaultRootWindow(display)
  
      C.XScreenSaverQueryInfo(display, defaultRootWindow, info)
      idleTime = info.idle
  
      return
  }
  </code></pre>
  
  <p>tried to compile with:</p>
  
  <pre><code>go build -gccgoflags="-lXss -lX11"
  </code></pre>
  
  <p>however i'm getting linker errors:</p>
  
  <blockquote>
    <p>/tmp/go-build076004816/opensource.stdk/lib/tools/_obj/x11.cgo2.o: In
    function <code>_cgo_c0e279f6f16e_Cfunc_XScreenSaverAllocInfo': ./x11.go:52:
    undefined reference to</code>XScreenSaverAllocInfo'
    /tmp/go-build076004816/opensource.stdk/lib/tools/_obj/x11.cgo2.o: In
    function <code>_cgo_c0e279f6f16e_Cfunc_XScreenSaverQueryInfo': ./x11.go:65:
    undefined reference to</code>XScreenSaverQueryInfo' collect2: error: ld
    returned 1 exit status</p>
  </blockquote>
  
  <p>what am i doing wrong?</p>