Importing define-modules with unbound variable error

Currently working on creating a guile program that has a few modules defined using (define-module (progname mod1)) these are the in ./progname directory. My main program in the root directory is simply called ./progname. I’m following the examples I see for multiple guile projects here like Haunt, Guile-zlib, Hoot.

In the main project where I called

(use-modules (progname mod1)
             (progname mod2)

I get ERROR: In procedure %resolve-variable: Unbound variable: mod2procedure.

I’ve tried adding (add-to-load-path "/path/to/progname/") and variations to the directory with no success. Also, when I run the code from the scheme all in one file it works correctly, and when I manually run the load-path above in a Guile REPL, the program works as well.

Any thoughts on how to get the modules known to the main program?

As far as I know you need to have progname in guile load path. When you install the program it should go in /usr/share/guile/site/3.0/progname and then it will automatically be in the loadpath.

When developing i usually interact with my programs through emacs geiser, so i use .dir-locals to set geiser-guile-load-path. If your program has a main entry point you could also make a bash script that exports GUILE_LOAD_PATH and then run guile progname/main.scm.

1 Like

My guess Is that the load-path needs to be the root directory of your libraries so it should be (add-to-load-path "/path/to") if you want to use (progname mod1) .