当我try 构建一个使用"github"的Go程序时.com/gordonklaus/portaudio和github.com/AllenDang/giu'我得了C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running x86_64-w64-mingw32-g++ failed: exit status 1

我想知道这是否与MINGW4中编译的portaudio有关

可复制示例:


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()
}

try 构建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 ```


推荐答案

这些错误表明您需要链接代码(或依赖项)所依赖的库.

try 添加这些链接器标志:

  • -Ishell32.
  • -lole32
  • -limm32
  • -lwinmm.
  • -liprop公司
  • -lsetupapi

Go相关问答推荐

无法在Macos上使用Azure Speech golang SDK

Golang使用Run()执行的命令没有返回

Golang内置打印(Ln)函数&S行为怪异

如何模拟go的Elastic search SDK?

当我有外键时,如何使用 GORM 创建数据库的新条目

Go 中的sync.Cond 与 Wait 方法

使用goqu无法获取响应

xml.Unmarshal 不支持的类型 struct

当客户端同时是服务器时,需要什么 mTLS 证书?

将值发送到 Channel 并在就绪时读取输出

Go 的垃圾收集器在使用时删除 ZeroMQ 套接字

如何为导入的嵌入式 struct 文字提供值?

使用 go.work 文件在多个测试文件上运行 go test 命令

如何在 golang revel 中获取动态应用程序配置

如何 Select 前 N 个元素 Gin-Gorm

是否可以使用按位运算在随机 unicode 字符串中找到重复字符?

在 golang 中联合一个接口和类型

将 Simple Go Web 应用程序部署到 Elastic Beanstalk

如何断言类型是指向golang中接口的指针

从类型别名转换为原始类型