From e520d9b6f336ead8f72d5d29ff11e1900a89222c Mon Sep 17 00:00:00 2001 From: Jan Svabenik Date: Thu, 19 Mar 2026 11:20:09 +0100 Subject: [PATCH] Fix Windows runtime DLL search for SDRplay and gpudemod --- build-sdrplay.ps1 | 21 +++++++++++++++------ internal/demod/gpudemod/gpudemod_windows.go | 3 +++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/build-sdrplay.ps1 b/build-sdrplay.ps1 index a731d63..a884df9 100644 --- a/build-sdrplay.ps1 +++ b/build-sdrplay.ps1 @@ -12,8 +12,11 @@ $env:CC = 'gcc' $env:CXX = 'g++' # SDRplay -$env:CGO_CFLAGS = '-IC:\PROGRA~1\SDRplay\API\inc' -$env:CGO_LDFLAGS = '-LC:\PROGRA~1\SDRplay\API\x64 -lsdrplay_api' +$sdrplayInc = 'C:\PROGRA~1\SDRplay\API\inc' +$sdrplayBin = 'C:\PROGRA~1\SDRplay\API\x64' +$env:CGO_CFLAGS = "-I$sdrplayInc" +$env:CGO_LDFLAGS = "-L$sdrplayBin -lsdrplay_api" +if (Test-Path $sdrplayBin) { $env:PATH = "$sdrplayBin;" + $env:PATH } # CUDA runtime / cuFFT $cudaInc = 'C:\CUDA\include' @@ -29,11 +32,17 @@ Write-Host 'Building SDRplay + cuFFT app (Windows DLL path)...' -ForegroundColor go build -tags "sdrplay,cufft" ./cmd/sdrd if ($LASTEXITCODE -ne 0) { throw 'build failed' } -$dllSrc = Join-Path $PSScriptRoot 'internal\demod\gpudemod\build\gpudemod_kernels.dll' +$dllCandidates = @( + (Join-Path $PSScriptRoot 'internal\demod\gpudemod\build\gpudemod_kernels.dll'), + (Join-Path $PSScriptRoot 'gpudemod_kernels.dll') +) $dllDst = Join-Path $PSScriptRoot 'gpudemod_kernels.dll' -if (Test-Path $dllSrc) { - Copy-Item $dllSrc $dllDst -Force - Write-Host "Copied DLL to $dllDst" -ForegroundColor Green +$dllSrc = $dllCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1 +if ($dllSrc) { + if ((Resolve-Path $dllSrc).Path -ne (Resolve-Path (Split-Path $dllDst -Parent)).Path + '\gpudemod_kernels.dll') { + Copy-Item $dllSrc $dllDst -Force + } + Write-Host "CUDA DLL ready at $dllDst" -ForegroundColor Green } else { Write-Host 'WARNING: gpudemod_kernels.dll not found; build succeeded but runtime GPU demod will not load.' -ForegroundColor Yellow } diff --git a/internal/demod/gpudemod/gpudemod_windows.go b/internal/demod/gpudemod/gpudemod_windows.go index daae728..5e17e0b 100644 --- a/internal/demod/gpudemod/gpudemod_windows.go +++ b/internal/demod/gpudemod/gpudemod_windows.go @@ -136,13 +136,16 @@ func ensureDLLLoaded() error { C.free(unsafe.Pointer(cp)) if res == 0 { loadErr = nil + fmt.Fprintf(os.Stderr, "gpudemod: loaded DLL %s\n", p) return } loadErr = fmt.Errorf("failed to load gpudemod DLL: %s (code %d)", p, int(res)) + fmt.Fprintf(os.Stderr, "gpudemod: DLL load failed for %s (code %d)\n", p, int(res)) } } if loadErr == nil { loadErr = errors.New("gpudemod_kernels.dll not found") + fmt.Fprintln(os.Stderr, "gpudemod: gpudemod_kernels.dll not found in search paths") } }) return loadErr