[racket-dev] distributing native code

From: John Clements (clements at brinckerhoff.org)
Date: Fri Sep 9 03:33:22 EDT 2011

As part of the PortAudio library, I want to be able to call this code:

void bufferAdd(short *dst, short *src, int len) {
  int i;
  for (i = 0; i<len; i++) {
    dst[i] += src[i];

... and I'm trying to figure out the most hassle-free way to distribute it, given that it may be installed on machines without compilers[*].  It looks to me like the best way is probably to explicitly add shared-object files to paths given by

(build-path "native" (system-library-subpath) (path-add-suffix "buffer-add" (system-type 'so-suffix))),

to distribute them as part of the package, and then to load these explicitly, signaling an error if one is not found. Note that I'm omitting the "compiled" part, because that would be deleted by a call to "raco setup --clean".

I looked through my existing plt tree, and was a bit startled to see that not a single collection includes any shared library that I could copy from.

Does this approach make sense?

Many thanks,


[*] See earlier thread where the general consensus was that it was not possible to make a Racket version of this run less than (IIRC) 5x slower than C.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4624 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20110909/e6563ee8/attachment.p7s>

Posted on the dev mailing list.