Closed roynalnaruto closed 3 years ago
Looks like your linker flags are not complete, I see that you use - {name: LDFLAGS, flags: ["-L${SRCDIR} -lmy_ffi"]}
which is not enough as all those symbols had to be linked too.
My advice is that you should create a hand-made .go file that will contain proper LDFLAGS or even pkg-config
CGO directive. See for reference:
On macOS in particular, you should link with frameworks too, example: https://github.com/vulkan-go/vulkan/blob/master/vulkan_darwin.go#L7
I managed to compile my codebase in both Linux and Darwin. On MacOS, I had to link frameworks as @xlab mentioned (Thanks a lot for that @xlab). For linux I had to link a few more libraries.
Finally, my generator config looks something like this:
FlagGroups:
- {name: "LDFLAGS", flags: [
"-L${SRCDIR}",
"-lmy_ffi",
]}
- {name: "linux LDFLAGS", flags: [
"-lcrypto",
"-ldl",
"-lm",
"-lrt",
"-lssl",
"-ludev",
]}
- {name: "darwin LDFLAGS", flags: [
"-F/Library/Frameworks",
"-framework Security",
"-framework CoreServices",
"-framework IOKit",
"-framework IOSurface",
"-framework AppKit",
]}
Closing the issue.
I have setup a Go-Rust FFI using c-for-go. I can successfully compile the Rust release as well as the C interface for it.
On trying to compile the generated
.go
files, I get the following error:Some of my machine specs:
cbindgen
in my Rust projectc-for-go
commandPARSER: Defines: __has_include_next(x): 1 IncludePaths:
TRANSLATOR: Rules: function:
stable-x86_64-apple-darwin
Am I missing certain headers? Unfortunately I couldn't find much relevant information about this error. Any help would be appreciated.