Home > Software engineering >  how to build a GO program using github.com/AllenDang/giu and github.com/gordonklaus/portaudio in Win
how to build a GO program using github.com/AllenDang/giu and github.com/gordonklaus/portaudio in Win

Time:06-07

When I try to build a Go program which uses 'github.com/gordonklaus/portaudio' and 'github.com/AllenDang/giu' I got C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running x86_64-w64-mingw32-g failed: exit status 1 When I tested to build Go programs using those packages separated ('github.com/gordonklaus/portaudio' and 'github.com/AllenDang/giu') the programs build properly and run as expected.

I am wondering if it is something related to the compiled portaudio in MINGW4

reproducible example:


import (
    "log"
    "os"
    "os/signal"

    g "github.com/AllenDang/giu"
    "github.com/go-audio/audio"
    "github.com/go-audio/generator"
    "github.com/gordonklaus/portaudio"
)

func RunAudio() {

    portaudio.Initialize()

    defer portaudio.Terminate()
    out := make([]float32, 2048)
    buf := &audio.FloatBuffer{
        Data:   make([]float64, 2048),
        Format: audio.FormatStereo44100,
    }
    //***************************
    currentNote := 440.0
    osc := generator.NewOsc(generator.WaveSine, currentNote, buf.Format.SampleRate)
    osc.Amplitude = 1
    osc.Freq = 440.0
    sig := make(chan os.Signal, 1)
    signal.Notify(sig, os.Interrupt, os.Kill)

    stream, err := portaudio.OpenDefaultStream(0, 2, 44100, len(out), &out)
    if err != nil {
        log.Fatal(err)
    }
    log.Println("dsp running")
    defer stream.Close()

    if err := stream.Start(); err != nil {
        log.Fatal(err)
    }
    defer stream.Stop()

    for {
        if err := osc.Fill(buf); err != nil {
            log.Printf("error filling up the buffer")
        }

        f64ToF32Mixing(out, buf)
        // write to the stream
        if err := stream.Write(); err != nil {
            log.Printf("error writing to stream : %v\n", err)
        }

    }

}

func f64ToF32Mixing(dst []float32, buf *audio.FloatBuffer) {
    for i := range buf.Data {
        dst[i] = float32(buf.Data[i])
    }

}
func loop() {
    g.Window("test").Layout(

        g.Label("hello world"),
    )
}

func main() {

    wnd := g.NewMasterWindow("Hello synth", 700, 700, g.MasterWindowFlagsTransparent)
    go wnd.Run(loop)
    RunAudio()
}

the stack error when I try to build runing go run -x main.go:

# command-line-arguments
C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running x86_64-w64-mingw32-g   failed: exit status 1
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_util.c.obj):(.text 0xda): undefined reference to `__imp_timeGetTime'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_ds.c.obj):(.text 0x142): undefined reference to `__imp_timeEndPeriod'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_ds.c.obj):(.text 0xd15): undefined reference to `__imp_timeGetDevCaps'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_ds.c.obj):(.text 0xd58): undefined reference to `__imp_timeBeginPeriod'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_ds.c.obj):(.text 0x2202): undefined reference to `__imp_timeEndPeriod'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x2f7): undefined reference to `__imp_waveOutWrite'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x2fe): undefined reference to `__imp_waveOutGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x457): undefined reference to `__imp_waveInAddBuffer'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x45e): undefined reference to `__imp_waveInGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x601): undefined reference to `__imp_waveOutReset'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x64a): undefined reference to `__imp_waveOutGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x6c9): undefined reference to `__imp_waveInReset'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x70e): undefined reference to `__imp_waveInGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x908): undefined reference to `__imp_waveOutOpen'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x94b): undefined reference to `__imp_waveOutGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0xa18): undefined reference to `__imp_waveInOpen'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0xa5b): undefined reference to `__imp_waveInGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0xb33): undefined reference to `__imp_waveOutUnprepareHeader'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0xc23): undefined reference to `__imp_waveInUnprepareHeader'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0xdfd): undefined reference to `__imp_waveInPrepareHeader'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0xe0c): undefined reference to `__imp_waveOutPrepareHeader'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0xe8c): undefined reference to `__imp_waveInUnprepareHeader'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0xf0a): undefined reference to `__imp_waveOutUnprepareHeader'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x1066): undefined reference to `__imp_waveInGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x16fc): undefined reference to `__imp_waveInAddBuffer'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x177b): undefined reference to `__imp_waveInGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x182d): undefined reference to `__imp_waveOutPause'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x186f): undefined reference to `__imp_waveOutGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x189e): undefined reference to `__imp_waveOutWrite'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x198c): undefined reference to `__imp_waveOutGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x1c35): undefined reference to `__imp_waveInStart'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x1c7c): undefined reference to `__imp_waveOutRestart'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x1d63): undefined reference to `__imp_waveOutReset'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x1d6a): undefined reference to `__imp_waveOutGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x1dc9): undefined reference to `__imp_waveInReset'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x1dd0): undefined reference to `__imp_waveInGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x2720): undefined reference to `__imp_waveOutGetPosition'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x2bd7): undefined reference to `__imp_waveInClose'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x2bfc): undefined reference to `__imp_waveInGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x2c6d): undefined reference to `__imp_waveOutClose'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x2c92): undefined reference to `__imp_waveOutGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x2fa5): undefined reference to `__imp_waveOutOpen'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x2ff1): undefined reference to `__imp_waveOutOpen'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x3049): undefined reference to `__imp_waveOutGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x3112): undefined reference to `__imp_waveInOpen'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x315a): undefined reference to `__imp_waveInOpen'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x31a2): undefined reference to `__imp_waveInGetErrorTextW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x4caa): undefined reference to `__imp_waveInMessage'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x4cdd): undefined reference to `__imp_waveOutMessage'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x4d16): undefined reference to `__imp_waveInGetNumDevs'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x4d2b): undefined reference to `__imp_waveOutGetNumDevs'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x4ee2): undefined reference to `__imp_waveInGetDevCapsW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x51da): undefined reference to `__imp_waveOutGetNumDevs'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wmme.c.obj):(.text 0x5652): undefined reference to `__imp_waveOutGetDevCapsW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x3525): undefined reference to `__imp_CoGetInterfaceAndReleaseStream'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x3599): undefined reference to `__imp_CoGetInterfaceAndReleaseStream'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x3969): undefined reference to `__imp_CoInitializeEx'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x39b9): undefined reference to `__imp_timeGetDevCaps'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x39d2): undefined reference to `__imp_timeBeginPeriod'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x3cb2): undefined reference to `__imp_timeEndPeriod'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x3db2): undefined reference to `__imp_CoUninitialize'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x3dc2): undefined reference to `__imp_CoUninitialize'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x3e82): undefined reference to `__imp_CoInitializeEx'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x3ec6): undefined reference to `__imp_timeGetDevCaps'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x3ee1): undefined reference to `__imp_timeBeginPeriod'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x43b1): undefined reference to `__imp_timeGetTime'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x44e3): undefined reference to `__imp_timeEndPeriod'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x46a2): undefined reference to `__imp_timeGetTime'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x46d2): undefined reference to `__imp_timeGetTime'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x4a27): undefined reference to `__imp_CoUninitialize'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x4a32): undefined reference to `__imp_CoUninitialize'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x542c): undefined reference to `__imp_CoMarshalInterThreadInterfaceInStream'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x54de): undefined reference to `__imp_CoGetInterfaceAndReleaseStream'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x5573): undefined reference to `__imp_CoMarshalInterThreadInterfaceInStream'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x569e): undefined reference to `__imp_CoGetInterfaceAndReleaseStream'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x5a94): undefined reference to `__imp_CoTaskMemFree'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x8284): undefined reference to `__imp_CoCreateInstance'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x8355): undefined reference to `__imp_CoTaskMemFree'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x85b3): undefined reference to `__imp_CoTaskMemFree'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x86d7): undefined reference to `__imp_CoTaskMemFree'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x87b4): undefined reference to `__imp_PropVariantClear'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x883e): undefined reference to `__imp_PropVariantClear'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x8894): undefined reference to `__imp_PropVariantClear'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x8ced): undefined reference to `__imp_PropVariantClear'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wasapi.c.obj):(.text 0x8cf9): undefined reference to `__imp_CoTaskMemFree'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x23b6): undefined reference to `__imp_timeEndPeriod'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x2502): undefined reference to `__imp_timeBeginPeriod'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x2656): undefined reference to `__imp_timeGetTime'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x5f13): undefined reference to `__imp_SetupDiGetClassDevsW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x5f27): undefined reference to `__imp_SetupDiGetDeviceInterfaceAlias'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x5fb3): undefined reference to `__imp_SetupDiEnumDeviceInterfaces'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x6112): undefined reference to `__imp_SetupDiGetDeviceInterfaceAlias'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x6194): undefined reference to `__imp_SetupDiGetDeviceInterfaceDetailW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x61fe): undefined reference to `__imp_SetupDiEnumDeviceInterfaces'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x6411): undefined reference to `__imp_SetupDiGetDeviceRegistryPropertyW'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x643a): undefined reference to `__imp_SetupDiOpenDeviceInterfaceRegKey'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x6499): undefined reference to `__imp_SetupDiDestroyDeviceInfoList'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x64a0): undefined reference to `__imp_waveInMessage'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x64cf): undefined reference to `__imp_waveOutMessage'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_wdmks.c.obj):(.text 0x6cd5): undefined reference to `__imp_SetupDiDestroyDeviceInfoList'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_coinitialize.c.obj):(.text 0x1b): undefined reference to `__imp_CoInitialize'
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/tools/msys64/mingw64/lib\libportaudio.a(pa_win_coinitialize.c.obj):(.text 0x11d): undefined reference to `__imp_CoUninitialize'
collect2.exe: error: ld returned 1 exit status ```


CodePudding user response:

The errors indicate you need to link with the libraries your code (or the dependencies) depends on.

Try adding these linker flags:

  • -lshell32
  • -lole32
  • -limm32
  • -lwinmm
  • -liprop
  • -lsetupapi

CodePudding user response:

as @Brecht Sanders suggested, using these flags the libraries get linked:

go run -x -ldflags "-extldflags '-lshell32 -lole32 -limm32 -lwinmm -liprop -lsetupapi'" main.go

  • Related