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