So I am working on a Swift project built using SPM which relies on a custom system module (C++ with a C interface).
So far I do the following:
I've built the C module as a static library
I created a .pc file, and included it in my system pkg_config path
I added the system module as a target in my swift package, with the associated umbrella header and modulemap
It seems as if the system module is being discovered and included successfully, because I am able to use types declared in the C header files in my Swift code.
However: when I try to call a function defined in one of the .c files, I get the following error:
[1/3] Compiling MyModule main.swift
[2/4] Merging module MyModule
/swift-client/Sources/MyModule/main.swift:67: error: undefined reference to 'my_c_func'
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)
So if I can understand correctly, it looks like the linker cannot find the implementation of my function. Is that correct?
Does that mean I have failed to build my static lib (.a) correctly? Or is it an issue of failing to provide the correct flags in my .pc file?
What is the best way to debug this issue?