Skip to content

Instantly share code, notes, and snippets.

@billywhizz
Last active May 28, 2024 19:44
Show Gist options
  • Save billywhizz/b056fedf41f58f2be8971f2103b264cf to your computer and use it in GitHub Desktop.
Save billywhizz/b056fedf41f58f2be8971f2103b264cf to your computer and use it in GitHub Desktop.
Example of Creating a shared library binding for lo.js

** warning: lo.js is experimental and you should run it in a container or somewhere you don't care too much about until it has a stable release **

# clone this gist somewhere
git clone https://gist.github.com/billywhizz/b056fedf41f58f2be8971f2103b264cf
# rename the folder to hello - lo will use the parent folder name as the name 
# of the "app"
mv b056fedf41f58f2be8971f2103b264cf hello
cd hello
# initialise the "app"
lo init
# create and compile a dummy binding in lib/foo
lo build binding foo
# run the script, which will load the binding as a shared library
lo hello.js
# build an app from hello.js
lo build runtime hello
# the app will find the shared library and load it dynamically
./hello

🍹

const { foo }= lo.load('foo')
lo.assert(foo.noop() === undefined)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment