C/C++ Interop

My understaffed is horror we can get something like: https://docs.modular.com/mojo/roadmap#cc-interop And for clib interop we have sys.ffi.external_call My question is if I have a foo-lib.so that is a c/c++ lob, how can I call it's functions, and do I need the foo.h also?
Mojo🔥 roadmap & sharp edges | Modular Docs
A summary of our Mojo plans, including upcoming features and things we need to fix.
2 Replies
DobyDabaDu
DobyDabaDu5d ago
You can call .so functions using DLHandle. There is a simple example here: https://github.com/yetalit/Terminal-SnakeGame/tree/main/src/lib
GitHub
Terminal-SnakeGame/src/lib at main · yetalit/Terminal-SnakeGame
Terminal snake game from scratch (without 3rd party libraries) in mojo and a bit of C - yetalit/Terminal-SnakeGame
Darkmatter
Darkmatter5d ago
external_call is an escape hatch provided while the full interop is in progress. Eventually it will fade into an implementation detail for most users. You will still need a header file because a shared object file (.so) only gives you a function body, and the header file is needed to figure out what arguments to call the function with.
Want results from more Discord servers?
Add your server