FAQ
Hi

Can someone help me understand how to build a package that uses C files
please.

I'm using Intellij IDEA and trying to build the portaudio package into my
project. The project also uses Roger Peppe's callback package.
I've added the required audio files into an existing audio package I have
and created a callback package. These packages contain the go code, c code
and all headers.
If I just point to these directories and use cgo directly both build an
object file in packagename/_obj.
If I use the IDE it does build a callback library in go-bins/callback/_obj
but not a portaudio library.

I get the following complaints:
portaudio.go:10[audio/_obj/portaudio.cgo1.go:9]: can't find import:
"callback"
C:\GoSdr\src\callback\callback.go
can't find import: "C"
C:\GoSdr\src\audio\portaudio.go
can't find import: "C"

I'm not sure that IDEA knows to use cgo but it does seem to build
something.
Any help appreciated.

Bob

--
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

  • Gordon Klaus at Apr 1, 2013 at 10:53 pm
    portaudio-go is go gettable:

    go get code.google.com/p/portaudio-go/portaudio


    I don't know anything about Intellij IDEA.
    On Monday, April 1, 2013 3:20:25 PM UTC-4, bobc wrote:

    Hi

    Can someone help me understand how to build a package that uses C files
    please.

    I'm using Intellij IDEA and trying to build the portaudio package into my
    project. The project also uses Roger Peppe's callback package.
    I've added the required audio files into an existing audio package I have
    and created a callback package. These packages contain the go code, c code
    and all headers.
    If I just point to these directories and use cgo directly both build an
    object file in packagename/_obj.
    If I use the IDE it does build a callback library in go-bins/callback/_obj
    but not a portaudio library.

    I get the following complaints:
    portaudio.go:10[audio/_obj/portaudio.cgo1.go:9]: can't find import:
    "callback"
    C:\GoSdr\src\callback\callback.go
    can't find import: "C"
    C:\GoSdr\src\audio\portaudio.go
    can't find import: "C"

    I'm not sure that IDEA knows to use cgo but it does seem to build
    something.
    Any help appreciated.

    Bob
    --
    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 Apr 1, 2013 at 11:11 pm
    Can you please post the output of `go env`, I believe your Go installation
    has not been compiled with cgo support.

    On Tue, Apr 2, 2013 at 6:20 AM, bobc wrote:

    Hi

    Can someone help me understand how to build a package that uses C files
    please.

    I'm using Intellij IDEA and trying to build the portaudio package into my
    project. The project also uses Roger Peppe's callback package.
    I've added the required audio files into an existing audio package I have
    and created a callback package. These packages contain the go code, c code
    and all headers.
    If I just point to these directories and use cgo directly both build an
    object file in packagename/_obj.
    If I use the IDE it does build a callback library in go-bins/callback/_obj
    but not a portaudio library.

    I get the following complaints:
    portaudio.go:10[audio/_obj/portaudio.cgo1.go:9]: can't find import:
    "callback"
    C:\GoSdr\src\callback\callback.go
    can't find import: "C"
    C:\GoSdr\src\audio\portaudio.go
    can't find import: "C"

    I'm not sure that IDEA knows to use cgo but it does seem to build
    something.
    Any help appreciated.

    Bob

    --
    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.
  • Bobc at Apr 2, 2013 at 8:43 am
    Hi Dave

    As requested.
    set GOARCH=386
    set GOBIN=
    set GOCHAR=8
    set GOEXE=.exe
    set GOGCCFLAGS=-g -O2 -m32 -mthreads
    set GOHOSTARCH=386
    set GOHOSTOS=windows
    set GOOS=windows
    set GOPATH=C:\GoSdr
    set GOROOT=C:\Go
    set GOTOOLDIR=C:\Go\pkg\tool\windows_386
    set CGO_ENABLED=1

    Bob
    On Monday, April 1, 2013 8:20:25 PM UTC+1, bobc wrote:

    Hi

    Can someone help me understand how to build a package that uses C files
    please.

    I'm using Intellij IDEA and trying to build the portaudio package into my
    project. The project also uses Roger Peppe's callback package.
    I've added the required audio files into an existing audio package I have
    and created a callback package. These packages contain the go code, c code
    and all headers.
    If I just point to these directories and use cgo directly both build an
    object file in packagename/_obj.
    If I use the IDE it does build a callback library in go-bins/callback/_obj
    but not a portaudio library.

    I get the following complaints:
    portaudio.go:10[audio/_obj/portaudio.cgo1.go:9]: can't find import:
    "callback"
    C:\GoSdr\src\callback\callback.go
    can't find import: "C"
    C:\GoSdr\src\audio\portaudio.go
    can't find import: "C"

    I'm not sure that IDEA knows to use cgo but it does seem to build
    something.
    Any help appreciated.

    Bob
    --
    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.
  • Bobc at Apr 2, 2013 at 8:48 am
    Hi Gorden

    I did try that but it didn't build, couldn't find pthread headers and I
    wasn't sure where it was supposed to pick things up from or where I could
    define includes etc.

    Bob


    --
    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.
  • Gordon Klaus at Apr 2, 2013 at 1:37 pm
    Sorry, I've not tried to build portaudio-go on Windows. The callback
    package is the one looking for pthreads. I guess the include path is
    dependent on your coding environment, what are you using, MinGW?
    On Tuesday, April 2, 2013 4:48:48 AM UTC-4, bobc wrote:

    Hi Gorden

    I did try that but it didn't build, couldn't find pthread headers and I
    wasn't sure where it was supposed to pick things up from or where I could
    define includes etc.

    Bob

    --
    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.
  • Bobc at Apr 2, 2013 at 6:35 pm
    As far as I can tell the plugin for IDEA will use MinGW gcc for cgo
    compilation. The MinGW directories do have pthread headers and libraries
    but I'm wondering if I need some env vars set up to use it. Below is the
    error from the build. I want this cross platform but usually start with
    Windows as its always the awkward one.

    C:\Users\bob>go get code.google.com/p/portaudio-go/portaudio
    # code.google.com/p/rog-go/exp/callback
    C:\Users\bob\AppData\Local\Temp\go-build984479975\code.google.com\p\rog-go\exp\callback\_obj\callback.o:
    In function `callback':
    C:/GoSdr/src/code.google.com/p/rog-go/exp/callback/callback.c:81: undefined
    reference to `_imp__pthread_mutex_lock'
    C:/GoSdr/src/code.google.com/p/rog-go/exp/callback/callback.c:96: undefined
    reference to `_imp__pthread_cond_signal'
    C:/GoSdr/src/code.google.com/p/rog-go/exp/callback/callback.c:97: undefined
    reference to `_imp__pthread_cond_wait'
    C:/GoSdr/src/code.google.com/p/rog-go/exp/callback/callback.c:102:
    undefined reference to `_imp__pthread_mutex_unlock'
    C:/GoSdr/src/code.google.com/p/rog-go/exp/callback/callback.c:87: undefined
    reference to `_imp__pthread_cond_init'
    C:\Users\bob\AppData\Local\Temp\go-build984479975\code.google.com\p\rog-go\exp\callback\_obj\callback.o:
    In function `callbackInit':
    C:/GoSdr/src/code.google.com/p/rog-go/exp/callback/callback.c:30: undefined
    reference to `_imp__pthread_mutex_init'
    C:/GoSdr/src/code.google.com/p/rog-go/exp/callback/callback.c:31: undefined
    reference to `_imp__pthread_cond_init'
    C:\Users\bob\AppData\Local\Temp\go-build984479975\code.google.com\p\rog-go\exp\callback\_obj\callback.o:
    In function `runCallbacks':
    C:/GoSdr/src/code.google.com/p/rog-go/exp/callback/callback.c:41: undefined
    reference to `_imp__pthread_mutex_lock'
    C:/GoSdr/src/code.google.com/p/rog-go/exp/callback/callback.c:41: undefined
    reference to `_imp__pthread_mutex_unlock'
    C:/GoSdr/src/code.google.com/p/rog-go/exp/callback/callback.c:41: undefined
    reference to `_imp__pthread_cond_signal'
    C:/GoSdr/src/code.google.com/p/rog-go/exp/callback/callback.c:45: undefined
    reference to `_imp__pthread_cond_wait'
    collect2: ld returned 1 exit status
    On Tuesday, April 2, 2013 2:36:59 PM UTC+1, gordon...@gmail.com wrote:

    Sorry, I've not tried to build portaudio-go on Windows. The callback
    package is the one looking for pthreads. I guess the include path is
    dependent on your coding environment, what are you using, MinGW?
    On Tuesday, April 2, 2013 4:48:48 AM UTC-4, bobc wrote:

    Hi Gorden

    I did try that but it didn't build, couldn't find pthread headers and I
    wasn't sure where it was supposed to pick things up from or where I could
    define includes etc.

    Bob

    --
    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
postedApr 1, '13 at 7:20p
activeApr 2, '13 at 6:35p
posts7
users3
websitegolang.org

3 users in discussion

Bobc: 4 posts Gordon Klaus: 2 posts Dave Cheney: 1 post

People

Translate

site design / logo © 2022 Grokbase