FAQ
I'm attempting to write a process monitor by linking to sigar api.
After reading cgo docs, I feel like I'm close to getting this to work, but
given the code at
https://bitbucket.org/turne016/process-monitor, I can't figure out how to
satisfy the compiler when doing "go install
bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

Can anybody shed some light on this and how cgo works with regards to
passing parameters to C libraries.


Thanks!
Shane

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Dave Cheney at Feb 5, 2014 at 12:32 am
    What is the error that you receive ?

    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner wrote:

    I'm attempting to write a process monitor by linking to sigar api.
    After reading cgo docs, I feel like I'm close to getting this to work, but
    given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure out how to
    satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with regards to
    passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shane Turner at Feb 5, 2014 at 12:53 am
    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20: cannot
    use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte in
    function argument

    I just can't seem to figure out how to pass around the parameters in a way
    to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?


    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner <kola...@gmail.com<javascript:>
    wrote:
    I'm attempting to write a process monitor by linking to sigar api.
    After reading cgo docs, I feel like I'm close to getting this to work,
    but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure out how
    to satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with regards to
    passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dave Cheney at Feb 5, 2014 at 1:03 am
    C.sigar_open(&sigar)


    ^ guess


    On Wed, Feb 5, 2014 at 11:53 AM, Shane Turner wrote:


    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20: cannot
    use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte in
    function argument

    I just can't seem to figure out how to pass around the parameters in a way
    to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?

    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner wrote:

    I'm attempting to write a process monitor by linking to sigar api.
    After reading cgo docs, I feel like I'm close to getting this to work,
    but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure out how
    to satisfy the compiler when doing "go install bitbucket.org/turne016/
    process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with regards to
    passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shane Turner at Feb 5, 2014 at 1:12 am
    just tried the following.

    func memory() C.sigar_mem_t {
         var sigar C.sigar_t
         var sigar_mem C.sigar_mem_t
    ** C.sigar_open(&sigar)
         C.sigar_mem_get(&sigar, &sigar_mem)
         fmt.Println("sigar: %+v", sigar)
         return sigar_mem
    }

    The ** line gives the following error: proc_cpu_windows.go:20: cannot use
    &sigar (type *[0]byte) as type **[0]byte in function argument
    On Tuesday, February 4, 2014 7:03:35 PM UTC-6, Dave Cheney wrote:

    C.sigar_open(&sigar)


    ^ guess



    On Wed, Feb 5, 2014 at 11:53 AM, Shane Turner <kola...@gmail.com<javascript:>
    wrote:
    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20:
    cannot use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte
    in function argument

    I just can't seem to figure out how to pass around the parameters in a
    way to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?

    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner wrote:

    I'm attempting to write a process monitor by linking to sigar api.
    After reading cgo docs, I feel like I'm close to getting this to work,
    but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure out how
    to satisfy the compiler when doing "go install bitbucket.org/turne016/
    process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with regards to
    passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shane Turner at Feb 5, 2014 at 1:16 am
    ok, just got a bit further, noticed the open call is **sigar_t (not
    *sigar_t), so this appeared to work.
      sigar := new(C.sigar_t)
      var sigar_mem C.sigar_mem_t
      C.sigar_open(&sigar)
      C.sigar_mem_get(sigar, &sigar_mem)
      fmt.Println("sigar: %+v", sigar)
      return sigar_mem

    however, the next failure is
    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    which looks like something with the linker maybe not finding my libraries
    or something (rusty on my -L -I -l stuff from C days)

    On Tuesday, February 4, 2014 7:12:04 PM UTC-6, Shane Turner wrote:

    just tried the following.

    func memory() C.sigar_mem_t {
    var sigar C.sigar_t
    var sigar_mem C.sigar_mem_t
    ** C.sigar_open(&sigar)
    C.sigar_mem_get(&sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem
    }

    The ** line gives the following error: proc_cpu_windows.go:20: cannot use
    &sigar (type *[0]byte) as type **[0]byte in function argument
    On Tuesday, February 4, 2014 7:03:35 PM UTC-6, Dave Cheney wrote:

    C.sigar_open(&sigar)


    ^ guess


    On Wed, Feb 5, 2014 at 11:53 AM, Shane Turner wrote:


    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20:
    cannot use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte
    in function argument

    I just can't seem to figure out how to pass around the parameters in a
    way to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?

    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner wrote:

    I'm attempting to write a process monitor by linking to sigar api.
    After reading cgo docs, I feel like I'm close to getting this to work,
    but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure out
    how to satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with regards to
    passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shane Turner at Feb 5, 2014 at 1:31 am
    After running build with -x option, it appears the last step using 8l.exe,
    it doesn't find my library. I can see my LDFLAGS being used during "gcc"
    compile, but
    I don't see it being used by 8l.exe. Are they used by 8l.exe?

    FYI, Windows 7, GOOS=windows, GOARCH=386 and it's attempting to link to a
    static sigar library. All of that is checked into the repo.


    On Tuesday, February 4, 2014 7:16:28 PM UTC-6, Shane Turner wrote:

    ok, just got a bit further, noticed the open call is **sigar_t (not
    *sigar_t), so this appeared to work.
    sigar := new(C.sigar_t)
    var sigar_mem C.sigar_mem_t
    C.sigar_open(&sigar)
    C.sigar_mem_get(sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem

    however, the next failure is
    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    which looks like something with the linker maybe not finding my libraries
    or something (rusty on my -L -I -l stuff from C days)

    On Tuesday, February 4, 2014 7:12:04 PM UTC-6, Shane Turner wrote:

    just tried the following.

    func memory() C.sigar_mem_t {
    var sigar C.sigar_t
    var sigar_mem C.sigar_mem_t
    ** C.sigar_open(&sigar)
    C.sigar_mem_get(&sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem
    }

    The ** line gives the following error: proc_cpu_windows.go:20: cannot use
    &sigar (type *[0]byte) as type **[0]byte in function argument
    On Tuesday, February 4, 2014 7:03:35 PM UTC-6, Dave Cheney wrote:

    C.sigar_open(&sigar)


    ^ guess


    On Wed, Feb 5, 2014 at 11:53 AM, Shane Turner wrote:


    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20:
    cannot use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte
    in function argument

    I just can't seem to figure out how to pass around the parameters in a
    way to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?

    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner wrote:

    I'm attempting to write a process monitor by linking to sigar api.
    After reading cgo docs, I feel like I'm close to getting this to
    work, but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure out
    how to satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with regards to
    passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dave Cheney at Feb 5, 2014 at 1:40 am
    Please post the output of -x

    On Wed, Feb 5, 2014 at 12:31 PM, Shane Turner wrote:

    After running build with -x option, it appears the last step using 8l.exe,
    it doesn't find my library. I can see my LDFLAGS being used during "gcc"
    compile, but
    I don't see it being used by 8l.exe. Are they used by 8l.exe?

    FYI, Windows 7, GOOS=windows, GOARCH=386 and it's attempting to link to a
    static sigar library. All of that is checked into the repo.


    On Tuesday, February 4, 2014 7:16:28 PM UTC-6, Shane Turner wrote:

    ok, just got a bit further, noticed the open call is **sigar_t (not
    *sigar_t), so this appeared to work.
    sigar := new(C.sigar_t)
    var sigar_mem C.sigar_mem_t
    C.sigar_open(&sigar)
    C.sigar_mem_get(sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem

    however, the next failure is
    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    which looks like something with the linker maybe not finding my libraries
    or something (rusty on my -L -I -l stuff from C days)

    On Tuesday, February 4, 2014 7:12:04 PM UTC-6, Shane Turner wrote:

    just tried the following.

    func memory() C.sigar_mem_t {
    var sigar C.sigar_t
    var sigar_mem C.sigar_mem_t
    ** C.sigar_open(&sigar)
    C.sigar_mem_get(&sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem
    }

    The ** line gives the following error: proc_cpu_windows.go:20: cannot
    use &sigar (type *[0]byte) as type **[0]byte in function argument
    On Tuesday, February 4, 2014 7:03:35 PM UTC-6, Dave Cheney wrote:

    C.sigar_open(&sigar)


    ^ guess


    On Wed, Feb 5, 2014 at 11:53 AM, Shane Turner wrote:


    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20:
    cannot use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte
    in function argument

    I just can't seem to figure out how to pass around the parameters in a
    way to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?

    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner wrote:

    I'm attempting to write a process monitor by linking to sigar api.
    After reading cgo docs, I feel like I'm close to getting this to
    work, but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure out
    how to satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with regards
    to passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shane Turner at Feb 5, 2014 at 2:09 am
    See attached.
    On Tuesday, February 4, 2014 7:40:09 PM UTC-6, Dave Cheney wrote:

    Please post the output of -x


    On Wed, Feb 5, 2014 at 12:31 PM, Shane Turner <kola...@gmail.com<javascript:>
    wrote:
    After running build with -x option, it appears the last step using
    8l.exe, it doesn't find my library. I can see my LDFLAGS being used during
    "gcc" compile, but
    I don't see it being used by 8l.exe. Are they used by 8l.exe?

    FYI, Windows 7, GOOS=windows, GOARCH=386 and it's attempting to link to a
    static sigar library. All of that is checked into the repo.


    On Tuesday, February 4, 2014 7:16:28 PM UTC-6, Shane Turner wrote:

    ok, just got a bit further, noticed the open call is **sigar_t (not
    *sigar_t), so this appeared to work.
    sigar := new(C.sigar_t)
    var sigar_mem C.sigar_mem_t
    C.sigar_open(&sigar)
    C.sigar_mem_get(sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem

    however, the next failure is
    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    which looks like something with the linker maybe not finding my
    libraries or something (rusty on my -L -I -l stuff from C days)

    On Tuesday, February 4, 2014 7:12:04 PM UTC-6, Shane Turner wrote:

    just tried the following.

    func memory() C.sigar_mem_t {
    var sigar C.sigar_t
    var sigar_mem C.sigar_mem_t
    ** C.sigar_open(&sigar)
    C.sigar_mem_get(&sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem
    }

    The ** line gives the following error: proc_cpu_windows.go:20: cannot
    use &sigar (type *[0]byte) as type **[0]byte in function argument
    On Tuesday, February 4, 2014 7:03:35 PM UTC-6, Dave Cheney wrote:

    C.sigar_open(&sigar)



    ^ guess


    On Wed, Feb 5, 2014 at 11:53 AM, Shane Turner wrote:


    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20:
    cannot use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte
    in function argument

    I just can't seem to figure out how to pass around the parameters in
    a way to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?

    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner wrote:

    I'm attempting to write a process monitor by linking to sigar api.
    After reading cgo docs, I feel like I'm close to getting this to
    work, but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure out
    how to satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with regards
    to passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dave Cheney at Feb 5, 2014 at 2:27 am
    The problem is -L../../../../sigar-1.6.4/lib is passed to the linker, but
    because the path is relative and the linker runs in the temporary build
    directory.

    You could try adjusting the LDFLAGS section to be an absolutely path. I am
    sorry, I do not know a portable way of doing this.

    On Wed, Feb 5, 2014 at 1:09 PM, Shane Turner wrote:

    See attached.

    On Tuesday, February 4, 2014 7:40:09 PM UTC-6, Dave Cheney wrote:

    Please post the output of -x

    On Wed, Feb 5, 2014 at 12:31 PM, Shane Turner wrote:

    After running build with -x option, it appears the last step using
    8l.exe, it doesn't find my library. I can see my LDFLAGS being used during
    "gcc" compile, but
    I don't see it being used by 8l.exe. Are they used by 8l.exe?

    FYI, Windows 7, GOOS=windows, GOARCH=386 and it's attempting to link to
    a static sigar library. All of that is checked into the repo.


    On Tuesday, February 4, 2014 7:16:28 PM UTC-6, Shane Turner wrote:

    ok, just got a bit further, noticed the open call is **sigar_t (not
    *sigar_t), so this appeared to work.
    sigar := new(C.sigar_t)
    var sigar_mem C.sigar_mem_t
    C.sigar_open(&sigar)
    C.sigar_mem_get(sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem

    however, the next failure is
    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    which looks like something with the linker maybe not finding my
    libraries or something (rusty on my -L -I -l stuff from C days)

    On Tuesday, February 4, 2014 7:12:04 PM UTC-6, Shane Turner wrote:

    just tried the following.

    func memory() C.sigar_mem_t {
    var sigar C.sigar_t
    var sigar_mem C.sigar_mem_t
    ** C.sigar_open(&sigar)
    C.sigar_mem_get(&sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem
    }

    The ** line gives the following error: proc_cpu_windows.go:20: cannot
    use &sigar (type *[0]byte) as type **[0]byte in function argument
    On Tuesday, February 4, 2014 7:03:35 PM UTC-6, Dave Cheney wrote:

    C.sigar_open(&sigar)



    ^ guess


    On Wed, Feb 5, 2014 at 11:53 AM, Shane Turner wrote:


    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20:
    cannot use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte
    in function argument

    I just can't seem to figure out how to pass around the parameters in
    a way to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?

    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner wrote:

    I'm attempting to write a process monitor by linking to sigar api.
    After reading cgo docs, I feel like I'm close to getting this to
    work, but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure
    out how to satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with regards
    to passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dave Cheney at Feb 5, 2014 at 2:38 am
    https://code.google.com/p/go/issues/detail?id=5428

    On Wed, Feb 5, 2014 at 1:27 PM, Dave Cheney wrote:

    The problem is -L../../../../sigar-1.6.4/lib is passed to the linker, but
    because the path is relative and the linker runs in the temporary build
    directory.

    You could try adjusting the LDFLAGS section to be an absolutely path. I am
    sorry, I do not know a portable way of doing this.

    On Wed, Feb 5, 2014 at 1:09 PM, Shane Turner wrote:

    See attached.

    On Tuesday, February 4, 2014 7:40:09 PM UTC-6, Dave Cheney wrote:

    Please post the output of -x

    On Wed, Feb 5, 2014 at 12:31 PM, Shane Turner wrote:

    After running build with -x option, it appears the last step using
    8l.exe, it doesn't find my library. I can see my LDFLAGS being used during
    "gcc" compile, but
    I don't see it being used by 8l.exe. Are they used by 8l.exe?

    FYI, Windows 7, GOOS=windows, GOARCH=386 and it's attempting to link to
    a static sigar library. All of that is checked into the repo.


    On Tuesday, February 4, 2014 7:16:28 PM UTC-6, Shane Turner wrote:

    ok, just got a bit further, noticed the open call is **sigar_t (not
    *sigar_t), so this appeared to work.
    sigar := new(C.sigar_t)
    var sigar_mem C.sigar_mem_t
    C.sigar_open(&sigar)
    C.sigar_mem_get(sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem

    however, the next failure is
    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    which looks like something with the linker maybe not finding my
    libraries or something (rusty on my -L -I -l stuff from C days)

    On Tuesday, February 4, 2014 7:12:04 PM UTC-6, Shane Turner wrote:

    just tried the following.

    func memory() C.sigar_mem_t {
    var sigar C.sigar_t
    var sigar_mem C.sigar_mem_t
    ** C.sigar_open(&sigar)
    C.sigar_mem_get(&sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem
    }

    The ** line gives the following error: proc_cpu_windows.go:20: cannot
    use &sigar (type *[0]byte) as type **[0]byte in function argument
    On Tuesday, February 4, 2014 7:03:35 PM UTC-6, Dave Cheney wrote:

    C.sigar_open(&sigar)




    ^ guess


    On Wed, Feb 5, 2014 at 11:53 AM, Shane Turner wrote:


    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20:
    cannot use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte
    in function argument

    I just can't seem to figure out how to pass around the parameters
    in a way to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?

    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner wrote:

    I'm attempting to write a process monitor by linking to sigar api.
    After reading cgo docs, I feel like I'm close to getting this to
    work, but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure
    out how to satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with
    regards to passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the
    Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shane Turner at Feb 5, 2014 at 2:48 pm
    I went back and put the absolute path into the file just to see if that
    will indeed solve it.
    I did that, but I still get the problem. I purposefully changed the -L to
    a bad path and I then got a different error from ld saying

    c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe:
    cannot find -lsigar-x86-winnt
    collect2.exe: error: ld returned 1 exit status

    Ok, that proved ld could not find my library at all (due to bad -L path) ,
    however when putting in the correct absolute path, I'm back to

    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    So it appears ld is finding my library sigar-x86-winnt, however I didn't
    get that error even when using relative pathing. Shouldn't ld
    have given that error earlier using the relative path?

    Attached is the go install -x

    Thanks again!

    On Tuesday, February 4, 2014 8:38:42 PM UTC-6, Dave Cheney wrote:

    https://code.google.com/p/go/issues/detail?id=5428


    On Wed, Feb 5, 2014 at 1:27 PM, Dave Cheney <da...@cheney.net<javascript:>
    wrote:
    The problem is -L../../../../sigar-1.6.4/lib is passed to the linker, but
    because the path is relative and the linker runs in the temporary build
    directory.

    You could try adjusting the LDFLAGS section to be an absolutely path. I
    am sorry, I do not know a portable way of doing this.


    On Wed, Feb 5, 2014 at 1:09 PM, Shane Turner <kola...@gmail.com<javascript:>
    wrote:
    See attached.

    On Tuesday, February 4, 2014 7:40:09 PM UTC-6, Dave Cheney wrote:

    Please post the output of -x

    On Wed, Feb 5, 2014 at 12:31 PM, Shane Turner wrote:

    After running build with -x option, it appears the last step using
    8l.exe, it doesn't find my library. I can see my LDFLAGS being used during
    "gcc" compile, but
    I don't see it being used by 8l.exe. Are they used by 8l.exe?

    FYI, Windows 7, GOOS=windows, GOARCH=386 and it's attempting to link
    to a static sigar library. All of that is checked into the repo.


    On Tuesday, February 4, 2014 7:16:28 PM UTC-6, Shane Turner wrote:

    ok, just got a bit further, noticed the open call is **sigar_t (not
    *sigar_t), so this appeared to work.
    sigar := new(C.sigar_t)
    var sigar_mem C.sigar_mem_t
    C.sigar_open(&sigar)
    C.sigar_mem_get(sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem

    however, the next failure is
    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    which looks like something with the linker maybe not finding my
    libraries or something (rusty on my -L -I -l stuff from C days)

    On Tuesday, February 4, 2014 7:12:04 PM UTC-6, Shane Turner wrote:

    just tried the following.

    func memory() C.sigar_mem_t {
    var sigar C.sigar_t
    var sigar_mem C.sigar_mem_t
    ** C.sigar_open(&sigar)
    C.sigar_mem_get(&sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem
    }

    The ** line gives the following error: proc_cpu_windows.go:20:
    cannot use &sigar (type *[0]byte) as type **[0]byte in function argument
    On Tuesday, February 4, 2014 7:03:35 PM UTC-6, Dave Cheney wrote:

    C.sigar_open(&sigar)





    ^ guess


    On Wed, Feb 5, 2014 at 11:53 AM, Shane Turner wrote:


    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20:
    cannot use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte
    in function argument

    I just can't seem to figure out how to pass around the parameters
    in a way to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?

    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner wrote:

    I'm attempting to write a process monitor by linking to sigar
    api.
    After reading cgo docs, I feel like I'm close to getting this to
    work, but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure
    out how to satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with
    regards to passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the
    Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from
    it, send an email to golang-nuts...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out
    .
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Ken Allen at Feb 5, 2014 at 3:32 pm
    Just FYI - https://github.com/cloudfoundry/gosigar

    That's pure go, no cgo needed.
    On Wednesday, February 5, 2014 9:48:32 AM UTC-5, Shane Turner wrote:

    I went back and put the absolute path into the file just to see if that
    will indeed solve it.
    I did that, but I still get the problem. I purposefully changed the -L to
    a bad path and I then got a different error from ld saying

    c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe:
    cannot find -lsigar-x86-winnt
    collect2.exe: error: ld returned 1 exit status

    Ok, that proved ld could not find my library at all (due to bad -L path) ,
    however when putting in the correct absolute path, I'm back to

    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    So it appears ld is finding my library sigar-x86-winnt, however I didn't
    get that error even when using relative pathing. Shouldn't ld
    have given that error earlier using the relative path?

    Attached is the go install -x

    Thanks again!

    On Tuesday, February 4, 2014 8:38:42 PM UTC-6, Dave Cheney wrote:

    https://code.google.com/p/go/issues/detail?id=5428

    On Wed, Feb 5, 2014 at 1:27 PM, Dave Cheney wrote:

    The problem is -L../../../../sigar-1.6.4/lib is passed to the linker,
    but because the path is relative and the linker runs in the temporary build
    directory.

    You could try adjusting the LDFLAGS section to be an absolutely path. I
    am sorry, I do not know a portable way of doing this.

    On Wed, Feb 5, 2014 at 1:09 PM, Shane Turner wrote:

    See attached.

    On Tuesday, February 4, 2014 7:40:09 PM UTC-6, Dave Cheney wrote:

    Please post the output of -x

    On Wed, Feb 5, 2014 at 12:31 PM, Shane Turner wrote:

    After running build with -x option, it appears the last step using
    8l.exe, it doesn't find my library. I can see my LDFLAGS being used during
    "gcc" compile, but
    I don't see it being used by 8l.exe. Are they used by 8l.exe?

    FYI, Windows 7, GOOS=windows, GOARCH=386 and it's attempting to link
    to a static sigar library. All of that is checked into the repo.


    On Tuesday, February 4, 2014 7:16:28 PM UTC-6, Shane Turner wrote:

    ok, just got a bit further, noticed the open call is **sigar_t (not
    *sigar_t), so this appeared to work.
    sigar := new(C.sigar_t)
    var sigar_mem C.sigar_mem_t
    C.sigar_open(&sigar)
    C.sigar_mem_get(sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem

    however, the next failure is
    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    which looks like something with the linker maybe not finding my
    libraries or something (rusty on my -L -I -l stuff from C days)

    On Tuesday, February 4, 2014 7:12:04 PM UTC-6, Shane Turner wrote:

    just tried the following.

    func memory() C.sigar_mem_t {
    var sigar C.sigar_t
    var sigar_mem C.sigar_mem_t
    ** C.sigar_open(&sigar)
    C.sigar_mem_get(&sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem
    }

    The ** line gives the following error: proc_cpu_windows.go:20:
    cannot use &sigar (type *[0]byte) as type **[0]byte in function argument
    On Tuesday, February 4, 2014 7:03:35 PM UTC-6, Dave Cheney wrote:

    C.sigar_open(&sigar)





    ^ guess


    On Wed, Feb 5, 2014 at 11:53 AM, Shane Turner wrote:


    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20:
    cannot use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte
    in function argument

    I just can't seem to figure out how to pass around the parameters
    in a way to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?


    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner <kola...@gmail.com
    wrote:
    I'm attempting to write a process monitor by linking to sigar
    api.
    After reading cgo docs, I feel like I'm close to getting this
    to work, but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure
    out how to satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with
    regards to passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the
    Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from
    it, send an email to golang-nuts...@googlegroups.com.

    For more options, visit https://groups.google.com/grou
    ps/opt_out.
    --
    You received this message because you are subscribed to the
    Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Ken Allen at Feb 5, 2014 at 3:33 pm
    Whoops, I see you are on windows so I guess that won't actually help you.
    On Wednesday, February 5, 2014 10:32:54 AM UTC-5, Ken Allen wrote:

    Just FYI - https://github.com/cloudfoundry/gosigar

    That's pure go, no cgo needed.
    On Wednesday, February 5, 2014 9:48:32 AM UTC-5, Shane Turner wrote:

    I went back and put the absolute path into the file just to see if that
    will indeed solve it.
    I did that, but I still get the problem. I purposefully changed the -L
    to a bad path and I then got a different error from ld saying

    c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe:
    cannot find -lsigar-x86-winnt
    collect2.exe: error: ld returned 1 exit status

    Ok, that proved ld could not find my library at all (due to bad -L path)
    , however when putting in the correct absolute path, I'm back to

    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    So it appears ld is finding my library sigar-x86-winnt, however I didn't
    get that error even when using relative pathing. Shouldn't ld
    have given that error earlier using the relative path?

    Attached is the go install -x

    Thanks again!

    On Tuesday, February 4, 2014 8:38:42 PM UTC-6, Dave Cheney wrote:

    https://code.google.com/p/go/issues/detail?id=5428

    On Wed, Feb 5, 2014 at 1:27 PM, Dave Cheney wrote:

    The problem is -L../../../../sigar-1.6.4/lib is passed to the linker,
    but because the path is relative and the linker runs in the temporary build
    directory.

    You could try adjusting the LDFLAGS section to be an absolutely path. I
    am sorry, I do not know a portable way of doing this.

    On Wed, Feb 5, 2014 at 1:09 PM, Shane Turner wrote:

    See attached.

    On Tuesday, February 4, 2014 7:40:09 PM UTC-6, Dave Cheney wrote:

    Please post the output of -x

    On Wed, Feb 5, 2014 at 12:31 PM, Shane Turner wrote:

    After running build with -x option, it appears the last step using
    8l.exe, it doesn't find my library. I can see my LDFLAGS being used during
    "gcc" compile, but
    I don't see it being used by 8l.exe. Are they used by 8l.exe?

    FYI, Windows 7, GOOS=windows, GOARCH=386 and it's attempting to link
    to a static sigar library. All of that is checked into the repo.


    On Tuesday, February 4, 2014 7:16:28 PM UTC-6, Shane Turner wrote:

    ok, just got a bit further, noticed the open call is **sigar_t (not
    *sigar_t), so this appeared to work.
    sigar := new(C.sigar_t)
    var sigar_mem C.sigar_mem_t
    C.sigar_open(&sigar)
    C.sigar_mem_get(sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem

    however, the next failure is
    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    which looks like something with the linker maybe not finding my
    libraries or something (rusty on my -L -I -l stuff from C days)

    On Tuesday, February 4, 2014 7:12:04 PM UTC-6, Shane Turner wrote:

    just tried the following.

    func memory() C.sigar_mem_t {
    var sigar C.sigar_t
    var sigar_mem C.sigar_mem_t
    ** C.sigar_open(&sigar)
    C.sigar_mem_get(&sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem
    }

    The ** line gives the following error: proc_cpu_windows.go:20:
    cannot use &sigar (type *[0]byte) as type **[0]byte in function argument
    On Tuesday, February 4, 2014 7:03:35 PM UTC-6, Dave Cheney wrote:

    C.sigar_open(&sigar)





    ^ guess


    On Wed, Feb 5, 2014 at 11:53 AM, Shane Turner wrote:


    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20:
    cannot use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte
    in function argument

    I just can't seem to figure out how to pass around the
    parameters in a way to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?


    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner <
    kola...@gmail.com> wrote:
    I'm attempting to write a process monitor by linking to sigar
    api.
    After reading cgo docs, I feel like I'm close to getting this
    to work, but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't
    figure out how to satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with
    regards to passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the
    Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from
    it, send an email to golang-nuts...@googlegroups.com.

    For more options, visit https://groups.google.com/grou
    ps/opt_out.
    --
    You received this message because you are subscribed to the
    Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from
    it, send an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out
    .
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shane Turner at Feb 6, 2014 at 2:19 am
    Ok, after finding this project and looking at this
    file: https://github.com/shadowmint/go-static-linking/blob/master/demo/src/bridge/bridge.go
    I figured that my LDFLAGS were wrong, so I modified them to be a complete
    path to the static library and now I'm getting the following

    C:\Users\sturner\AppData\Local\Temp\go-build230100871\bitbucket.org\turne016\process-monitor.a(_all.o):
    malformed pe file: unexpected flags 0xe0300020 for PE section .
    text

    Any ideas here? I'm beginning to think nobody has ever linked a windows
    static library . . .
    On Wednesday, February 5, 2014 8:48:32 AM UTC-6, Shane Turner wrote:

    I went back and put the absolute path into the file just to see if that
    will indeed solve it.
    I did that, but I still get the problem. I purposefully changed the -L to
    a bad path and I then got a different error from ld saying

    c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe:
    cannot find -lsigar-x86-winnt
    collect2.exe: error: ld returned 1 exit status

    Ok, that proved ld could not find my library at all (due to bad -L path) ,
    however when putting in the correct absolute path, I'm back to

    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    So it appears ld is finding my library sigar-x86-winnt, however I didn't
    get that error even when using relative pathing. Shouldn't ld
    have given that error earlier using the relative path?

    Attached is the go install -x

    Thanks again!

    On Tuesday, February 4, 2014 8:38:42 PM UTC-6, Dave Cheney wrote:

    https://code.google.com/p/go/issues/detail?id=5428

    On Wed, Feb 5, 2014 at 1:27 PM, Dave Cheney wrote:

    The problem is -L../../../../sigar-1.6.4/lib is passed to the linker,
    but because the path is relative and the linker runs in the temporary build
    directory.

    You could try adjusting the LDFLAGS section to be an absolutely path. I
    am sorry, I do not know a portable way of doing this.

    On Wed, Feb 5, 2014 at 1:09 PM, Shane Turner wrote:

    See attached.

    On Tuesday, February 4, 2014 7:40:09 PM UTC-6, Dave Cheney wrote:

    Please post the output of -x

    On Wed, Feb 5, 2014 at 12:31 PM, Shane Turner wrote:

    After running build with -x option, it appears the last step using
    8l.exe, it doesn't find my library. I can see my LDFLAGS being used during
    "gcc" compile, but
    I don't see it being used by 8l.exe. Are they used by 8l.exe?

    FYI, Windows 7, GOOS=windows, GOARCH=386 and it's attempting to link
    to a static sigar library. All of that is checked into the repo.


    On Tuesday, February 4, 2014 7:16:28 PM UTC-6, Shane Turner wrote:

    ok, just got a bit further, noticed the open call is **sigar_t (not
    *sigar_t), so this appeared to work.
    sigar := new(C.sigar_t)
    var sigar_mem C.sigar_mem_t
    C.sigar_open(&sigar)
    C.sigar_mem_get(sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem

    however, the next failure is
    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    which looks like something with the linker maybe not finding my
    libraries or something (rusty on my -L -I -l stuff from C days)

    On Tuesday, February 4, 2014 7:12:04 PM UTC-6, Shane Turner wrote:

    just tried the following.

    func memory() C.sigar_mem_t {
    var sigar C.sigar_t
    var sigar_mem C.sigar_mem_t
    ** C.sigar_open(&sigar)
    C.sigar_mem_get(&sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem
    }

    The ** line gives the following error: proc_cpu_windows.go:20:
    cannot use &sigar (type *[0]byte) as type **[0]byte in function argument
    On Tuesday, February 4, 2014 7:03:35 PM UTC-6, Dave Cheney wrote:

    C.sigar_open(&sigar)





    ^ guess


    On Wed, Feb 5, 2014 at 11:53 AM, Shane Turner wrote:


    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20:
    cannot use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte
    in function argument

    I just can't seem to figure out how to pass around the parameters
    in a way to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?


    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner <kola...@gmail.com
    wrote:
    I'm attempting to write a process monitor by linking to sigar
    api.
    After reading cgo docs, I feel like I'm close to getting this
    to work, but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure
    out how to satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with
    regards to passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the
    Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from
    it, send an email to golang-nuts...@googlegroups.com.

    For more options, visit https://groups.google.com/grou
    ps/opt_out.
    --
    You received this message because you are subscribed to the
    Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dave Cheney at Feb 6, 2014 at 2:26 am
    https://code.google.com/p/go/issues/detail?id=5106

    which looks like a duplicate of

    https://code.google.com/p/go/issues/detail?id=4069

    which is still open so may not (yet) be fixed at tip

    On Thu, Feb 6, 2014 at 1:19 PM, Shane Turner wrote:

    Ok, after finding this project and looking at this file:
    https://github.com/shadowmint/go-static-linking/blob/master/demo/src/bridge/bridge.go

    I figured that my LDFLAGS were wrong, so I modified them to be a complete
    path to the static library and now I'm getting the following

    C:\Users\sturner\AppData\Local\Temp\go-build230100871\bitbucket.org\turne016\process-monitor.a(_all.o):
    malformed pe file: unexpected flags 0xe0300020 for PE section .
    text

    Any ideas here? I'm beginning to think nobody has ever linked a windows
    static library . . .
    On Wednesday, February 5, 2014 8:48:32 AM UTC-6, Shane Turner wrote:

    I went back and put the absolute path into the file just to see if that
    will indeed solve it.
    I did that, but I still get the problem. I purposefully changed the -L
    to a bad path and I then got a different error from ld saying

    c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe:
    cannot find -lsigar-x86-winnt
    collect2.exe: error: ld returned 1 exit status

    Ok, that proved ld could not find my library at all (due to bad -L path)
    , however when putting in the correct absolute path, I'm back to

    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    So it appears ld is finding my library sigar-x86-winnt, however I didn't
    get that error even when using relative pathing. Shouldn't ld
    have given that error earlier using the relative path?

    Attached is the go install -x

    Thanks again!

    On Tuesday, February 4, 2014 8:38:42 PM UTC-6, Dave Cheney wrote:

    https://code.google.com/p/go/issues/detail?id=5428

    On Wed, Feb 5, 2014 at 1:27 PM, Dave Cheney wrote:

    The problem is -L../../../../sigar-1.6.4/lib is passed to the linker,
    but because the path is relative and the linker runs in the temporary build
    directory.

    You could try adjusting the LDFLAGS section to be an absolutely path. I
    am sorry, I do not know a portable way of doing this.

    On Wed, Feb 5, 2014 at 1:09 PM, Shane Turner wrote:

    See attached.

    On Tuesday, February 4, 2014 7:40:09 PM UTC-6, Dave Cheney wrote:

    Please post the output of -x

    On Wed, Feb 5, 2014 at 12:31 PM, Shane Turner wrote:

    After running build with -x option, it appears the last step using
    8l.exe, it doesn't find my library. I can see my LDFLAGS being used during
    "gcc" compile, but
    I don't see it being used by 8l.exe. Are they used by 8l.exe?

    FYI, Windows 7, GOOS=windows, GOARCH=386 and it's attempting to link
    to a static sigar library. All of that is checked into the repo.


    On Tuesday, February 4, 2014 7:16:28 PM UTC-6, Shane Turner wrote:

    ok, just got a bit further, noticed the open call is **sigar_t (not
    *sigar_t), so this appeared to work.
    sigar := new(C.sigar_t)
    var sigar_mem C.sigar_mem_t
    C.sigar_open(&sigar)
    C.sigar_mem_get(sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem

    however, the next failure is
    sigar_open(0): not defined
    sigar_mem_get(0): not defined

    which looks like something with the linker maybe not finding my
    libraries or something (rusty on my -L -I -l stuff from C days)

    On Tuesday, February 4, 2014 7:12:04 PM UTC-6, Shane Turner wrote:

    just tried the following.

    func memory() C.sigar_mem_t {
    var sigar C.sigar_t
    var sigar_mem C.sigar_mem_t
    ** C.sigar_open(&sigar)
    C.sigar_mem_get(&sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem
    }

    The ** line gives the following error: proc_cpu_windows.go:20:
    cannot use &sigar (type *[0]byte) as type **[0]byte in function argument
    On Tuesday, February 4, 2014 7:03:35 PM UTC-6, Dave Cheney wrote:

    C.sigar_open(&sigar)





    ^ guess


    On Wed, Feb 5, 2014 at 11:53 AM, Shane Turner wrote:


    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20:
    cannot use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte
    in function argument

    I just can't seem to figure out how to pass around the
    parameters in a way to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?


    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner <
    kola...@gmail.com> wrote:
    I'm attempting to write a process monitor by linking to sigar
    api.
    After reading cgo docs, I feel like I'm close to getting this
    to work, but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't
    figure out how to satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with
    regards to passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the
    Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from
    it, send an email to golang-nuts...@googlegroups.com.

    For more options, visit https://groups.google.com/grou
    ps/opt_out.
    --
    You received this message because you are subscribed to the
    Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from
    it, send an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out
    .
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dave Cheney at Feb 5, 2014 at 1:39 am
    Why did you do that?

    You had

    sigar := new(C.sigar_t) // sigar is of type *C.sigar_t

    but you changed it to

    var sigar C.sigar_t // sigat is of type C.sigar_t

    You need

    **C.sigar_t

    so try

    sigar := new(C.sigar_t)
    C.sigar_open(&sigar)


    On Wed, Feb 5, 2014 at 12:12 PM, Shane Turner wrote:

    just tried the following.

    func memory() C.sigar_mem_t {
    var sigar C.sigar_t
    var sigar_mem C.sigar_mem_t
    ** C.sigar_open(&sigar)
    C.sigar_mem_get(&sigar, &sigar_mem)
    fmt.Println("sigar: %+v", sigar)
    return sigar_mem
    }

    The ** line gives the following error: proc_cpu_windows.go:20: cannot use
    &sigar (type *[0]byte) as type **[0]byte in function argument
    On Tuesday, February 4, 2014 7:03:35 PM UTC-6, Dave Cheney wrote:

    C.sigar_open(&sigar)


    ^ guess


    On Wed, Feb 5, 2014 at 11:53 AM, Shane Turner wrote:


    src\bitbucket.org\turne016\process-monitor\proc_cpu_windows.go:20:
    cannot use uintptr(unsafe.Pointer(sigar)) (type uintptr) as type **[0]byte
    in function argument

    I just can't seem to figure out how to pass around the parameters in a
    way to satisfy the compiler.
    On Tuesday, February 4, 2014 6:32:33 PM UTC-6, Dave Cheney wrote:

    What is the error that you receive ?

    On Wed, Feb 5, 2014 at 11:30 AM, Shane Turner wrote:

    I'm attempting to write a process monitor by linking to sigar api.
    After reading cgo docs, I feel like I'm close to getting this to work,
    but given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure out
    how to satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with regards to
    passing parameters to C libraries.


    Thanks!
    Shane

    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shane Turner at Feb 6, 2014 at 1:20 am
    So has anybody successfully linked a static windows library (xxx.lib) into
    a golang application using cgo?
    I initially tried to use it via the shared dll and just use the straight
    dll library function calls, but those are so cumbersome. to write.

    I'm having no luck here!
    On Tuesday, February 4, 2014 6:30:49 PM UTC-6, Shane Turner wrote:

    I'm attempting to write a process monitor by linking to sigar api.
    After reading cgo docs, I feel like I'm close to getting this to work, but
    given the code at
    https://bitbucket.org/turne016/process-monitor, I can't figure out how to
    satisfy the compiler when doing "go install
    bitbucket.org/turne016/process-monitor" with CGO_ENABLED=1

    Can anybody shed some light on this and how cgo works with regards to
    passing parameters to C libraries.


    Thanks!
    Shane
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedFeb 5, '14 at 12:30a
activeFeb 6, '14 at 2:26a
posts18
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase