This directory demonstrates the creation of an executable from Mojo, which calls a C function in a statically-linked external library.
File overview:
demo.c
: exports the C functioncall_this
, which prints a greeting.call_demo.mojo
: Mojomain
function which callscall_this
usingexternal_call
. In order to statically linkcall_demo.mojo
againstlibdemo
, we use themojoc
helper script.Makefile
: builds and runs all code. On linux, the following output should be displayed:
gcc -static -c demo.c -o libdemo.a
mojoc call_demo.mojo -Slibdemo.a -o call_demo
./call_demo
<calling statically-linked function from mojo>
hello from static library
<returned to mojo>