how do i load a module? none of the docs seem to help... :(

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

how do i load a module? none of the docs seem to help... :(

masukomi
given the following simple module:

```scheme
; hello.scm
(module hello (greet)
  (import chicken)
  (import scheme)

  (define (greet)
    (print "hello world")))
```

I then generate `hello.import.scm` and `hello.so` with `csc`

What _exactly_ do i need to put in code in order to import the `hello`
module in such a way that when I compile the thing importing it with
`csc -static thing-importing-hello.scm` I don't get "csc: could not
find linked extension hello"

I've been able to get my modules to work via `(import ...)` in the
thing importing them. as long as i run it with `csi` but i can't
actually compile it. :/ I've tried many combinations of import, load,
require that are fine in 'csi', but still generate the same compiler
error when running `csc -static thing-importing-them.scm`

Any help would be greatly appreciated. I've been banging my head
against this for way too long.



- Kay Rhodes
https://masukomi.org

_______________________________________________
Chicken-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/chicken-users
Reply | Threaded
Open this post in threaded view
|

Re: how do i load a module? none of the docs seem to help... :(

Evan Hanson-4
Hi Kay,

On 2019-08-09 17:19, masukomi wrote:
> I then generate `hello.import.scm` and `hello.so` with `csc`
>
> What _exactly_ do i need to put in code in order to import the `hello`
> module in such a way that when I compile the thing importing it with
> `csc -static thing-importing-hello.scm` I don't get "csc: could not
> find linked extension hello"

hello.so is a dynamic library, so it won't work when compiling the
program with -static. For that, you need to compile hello.scm to an
object file and link it into the program. Assuming you're using CHICKEN
5.x, try this:

    $ csc -unit hello -cJ hello.scm
    $ csc -link hello -static thing-importing-them.scm
    $ ./thing-importing-them
    hello world

thing-importing-them.scm can contain just the following:

    (import (hello))
    (greet)

Cheers,

Evan

_______________________________________________
Chicken-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/chicken-users