Rust, C FFI script to return a Rust code

Hi everyone, I am learning Rust, C FFIs (goal is to write C code into Rust).

Where I am at the moment in the project is just before I link Rust to C and do bindings - with the script containing environmental variables, when I call them on Cargo - a segmentation fault resulted...with a long error message about the op system and (the C source code is from a NGINX) --- Chat GPT says I cannot call the script by cargo build .

Anyone with ideas or experience of something similar?

Thank you.

I don't know the specifics about your build setup, but perhaps this blog post I wrote a while ago might help as you may encounter some similar problems: Introducing tmux-rs | tmux-rs

When trying to use multiple languages together, it's usually necessary to have a good knowledge of the build process of both languages (and in your case the existing project).

I haven't built nginx from source, but you'll likely encounter the same situation I describe in the blog post. You need to decide if cargo "owns" the final linking step, or if you want to compile your rust code as a library and let the C code link to that library and call it. Both are painful to setup because it requires you understand how the existing project is built.

These resources should also be helpful: