Swift + libsocketcan + Raspbian Buster linking error

So, I’m perhaps making things difficult for myself but I’m trying to write some CAN apps on a RaspberryPi 4 and have successfully munged candump.c to do what I want in C but ideally I’d like to do the heavy lifting in Swift, because its not C. :)

I’ve successfully bridged Swift & C methods and can get symbols to compile, but it cannot find libsocketcan on link. The Swift module map looks like:

module CSocketCAN [system] {
	header "../../Headers/CSocketCAN-Bridging-Header.h"
	link “libsocketcan"
	export *
}

$ swift build
/usr/bin/ld.gold: error: cannot find -llibsocketcan
/usr/bin/ld.gold: error: cannot find -llibsocketcan
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
[4/5] Linking myApp

I’ve also tried to explicitly reference the library location on the Pi but then I get Dispatch linking errors:

module CSocketCAN [system] {
	header "../../Headers/CSocketCAN-Bridging-Header.h"
	link "/usr/lib/arm-linux-gnueabihf/libsocketcan.so.2"
	export *
}

$ swift build
<unknown>:0: warning: missing submodule 'CDispatch'
<unknown>:0: warning: missing submodule 'Dispatch'
<unknown>:0: error: cannot load underlying module for 'Dispatch'

Does anyone have any tips on how to link libsocketcan into Swift?

TIA

I don't have experience with libsocketcan, but from the error messages it looks like

	link “libsocketcan"

in your module needs to read

	link "socketcan"

i.e. remove the lib prefix so the linker command will be -lsocketcan (otherwise the linker would be looking for a liblibsocketcan library).

Thanks. That gets me further along. But then hit this. I wonder if socketcan is using libdispatch as well as what Foundation is bringing in for GCD.

$ swift build
<unknown>:0: warning: missing submodule '_SwiftDispatchOverlayShims'
<unknown>:0: error: missing required module '_SwiftDispatchOverlayShims'