[racket] C-extensions in DrRacket

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Jan 14 18:00:09 EST 2014

At Tue, 14 Jan 2014 22:05:57 +0100, Marc Groenewegen wrote:
> Hello,
> 
> I have a working C-extension for Racket. In the Racket CLI and the
> interactions window of DrRacket it works like a charm. However, I can't get
> it to work in the definitions window of DrRacket, which would be really
> useful as this is the interface for my students to develop their programs.
> 
> The problem seems to be that definitions in the extension are not 'seen'
> (or registered or something). The module is loaded (or at least found) but
> DrRacket complains that it doesn't have execute permission for it, which I
> don't understand.
> 
> In the C code I declared the extension to be a module and I tried both
> inclusion methods:
> 
> (load-extension "racket_extension.so")
>   and
> (require "racket_extension.rkt") ; which requires you put it in a folder
> relative to the current working folder as follows:
> "compiled/native/x86_64-linux/3m/racket_extension_rkt.so"
> 
> Neither method works. The first case gives no error, but the definitions of
> the external are not registered ("undefined").
> 
> In the second case DrRacket gives an error:
>   forbidden (execute) access to
> ....compiled/native/x86_64-linux/3m/racket_extension_rkt.so
> but why?
> 
> Does anyone have ideas how I can get this to work? What am I overlooking?

The `load-extension` call likely loads a module declaration, but it
does not `require` the module into the current namespace.

I'm not sure why the `require` fails in DrRacket. The error makes sense
for background expansion, where a guard will prevent the use of
extensions, and so that error will appear at the bottom of the window.
But the extension should load ok when you run the program.


Posted on the users mailing list.