I appear to be swimming upstream. There are all sorts of tutorials and 
references for *extending* Racket with C, but precious little about *embedding* 
it. Unfortunately, I require the latter. 

I have a file hw.rkt with the following contents:

#lang racket/base

(provide hw) 

(define (hw) 
 (displayln "Hello, world!")) 

I would like to write a C program which uses an embedded Racket runtime to load 
and call the (hw) procedure. 

Resources I've found so far:

* http://docs.racket-lang.org/inside/embedding.html#%28part._3m_.Embedding%29

I have built and run the example program successfully, and thereby learned how 
to call a procedure provided by racket/base. I assume the same pattern applies 
for any library compiled with raco ctool.  My efforts to apply this knowledge 
to hw.rkt have so far failed me, though.

* http://docs.racket-lang.org/raco/c-mods.html

This page appears to say that what I want to do is *possible*, and tells me how 
to compile hw.rkt to a C file (which I have successfully done), but not how to 
use it afterward. 

I have asked this question on Stack Overflow and on Reddit, to no avail:

http://stackoverflow.com/q/36286921/2209270

https://www.reddit.com/r/Racket/comments/4ci29u/call_userprovided_racket_procedure_from_c_xpost/

The Stack Overflow link also includes what I've tried so far, and the error 
messages I've received for my efforts. 

An ideal answer would provide an example program in C that I could copy, 
compile, and run. An acceptable answer would tell me which C functions I'm 
supposed to use, and how to invoke them. 

I will appreciate any assistance you're able to render. Thank you. 

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to