I am new to Go, so the answer is probably simple, but I can't figure it out.
I have installed the SoapySDR library on macOS using Homebrew. I have created a simple Go program that uses the go-soapy-sdr package which references the SoapySDR header files and also links to the SoapySDR dynamic library. Within almost all the *.go files in go-soapy-sdr are the following lines:
// #cgo CFLAGS: -g -Wall
// #cgo LDFLAGS: -lSoapySDR
// #include <SoapySDR/Device.h>
...
import "C"
When I run go run . from the command line in the directory containing my program, I get
the following output:
# github.com/pothosware/go-soapy-sdr/pkg/device
../../pkg/mod/github.com/pothosware/[email protected]/pkg/device/antenna.go:7:11: fatal error: 'SoapySDR/Device.h' file not found
#include <SoapySDR/Device.h>
^~~~~~~~~~~~~~~~~~~
so it is not finding the SoapySDR header files. And yes, they do exist; they are located at /opt/Homebrew/Cellar/soapysdr/0.8.1_1/include/SoapySDR.
Now if I change
// #cgo CFLAGS: -g -Wall
// #cgo LDFLAGS: -lSoapySDR
// #include <SoapySDR/Device.h>
to
// #cgo pkg-config: soapysdr
// #cgo CFLAGS: -g -Wall
// #include <SoapySDR/Device.h>
then the header files are found. But since this is a third party package that has been around and in use for 5 or more years, I don't want to create my own version of it. With the change, I run into problems further down the build chain, but that is a problem for another day.
How can I use go-soapy-sdr without changes? Is there something I need to add to the go compiler call or something that needs to be added to a file in my project? I am at a stand-still with this. And no, there is no documentation with the go-soapy-sdr package that says how to do it.
Any help would be greatly appreciated.