Re: Deploying a macOS app bundle with statically linked modules - "cannot load extension" error

Felix Winkelmann via Chicken-users <[email protected]> Thu, 25 Dec 2025 14:48:25 +0100
Newsgroups gmane.lisp.scheme.chicken
Message-ID <[email protected]>
On Wed Dec 24, 2025 at 10:30 PM CET, Rolando Abarca via Chicken-users wrote:
>
> I'm trying to deploy a CHICKEN application as a self-contained macOS app
> bundle, but I'm running into issues with module loading at runtime. I'd
> appreciate any guidance on the correct approach.

Hi, Rolando! Merry christmas to you!

> With -uses, the module code is statically linked into the binary and the
> toplevel runs at startup. However, when another module does (import
> mymodule), CHICKEN's runtime still calls load-extension looking for
> mymodule.so, which doesn't exist because the code is embedded in the binary.
>
> 1. What is the correct way to deploy a CHICKEN application with custom
> modules on macOS?

To get things running, I would avoid using units and such and start with
the simplest configuration: just compile everying to .so's (including the
import libraries) and ad them to the bundle. Use the "-deployed" option
for the main program to make sure the runtime linker path is added
with "install_name_tool(1)" (you can use the "-v" option to csc to see
the commands executed). You should also use -private-repository to
ensure eggs and modules are taken from the bundle.

Modules must be "registered" to access their executable code, this
is normally done via import libs, but can be compiled in, usually
when doing static linking. This can all be optimized, but I suggest
you start with the described process and try to tweak things later.

It's been a while since I looked at Mac deployment but it is definitely
doable, keep me posted about your progress.

cheers,
felix