[racket] Using raco exe

From: Norman Gray (norman at astro.gla.ac.uk)
Date: Fri Jun 11 09:43:40 EDT 2010

Greetings.

I'm having difficulty using raco to build a standalone executable which requires both web-server/servlet and an extension.  The raco documentation seems to suggest that I'm doing the right thing, but I'm getting an error I can't really parse.  Can anyone help?

The players:

    A web server application (which we'll call) s.ss
    And a librdf-extn_rkt.dylib C extension, installed in my user collections path, required by s.ss.
    Racket 5.0, and OS X 10.6

Things don't go as smoothly as I'd expect.  Viz:

% cat s.ss      
#lang racket
(require web-server/servlet)
(require rdf/librdf-extn)  # provides librdf:new-world amongst various others
(printf "server: world ~s~%" (librdf:new-world))
% racket -v -t s.ss  # running it with racket works
Welcome to Racket v5.0.
server: world #<cpointer:librdf-world>
% raco exe -o build/s s.ss
% build/s  # ...but a standalone version doesn't
link: reference (phase 0) to a variable in module '#%embedded:g3708:librdf-extn that is uninitialized (phase level 0); reference appears in module: '#%mzc:s in: librdf:new-world

 === context ===
#%mzc:s: [running body]
loop

% ls -l ~/Library/Racket/5.0/collects/rdf/compiled/native/i386-macosx/3m/librdf-extn_rkt.dylib
-rwxr-xr-x  1 norman  staff  97068 11 Jun 11:37 /Users/norman/Library/Racket/5.0/collects/rdf/compiled/native/i386-macosx/3m/librdf-extn_rkt.dylib
% 

Hmm: what is it you're telling me, racket dear?

The module librdf-extn is a C extension, providing an interface to an underlying C library.  It works OK if I remove the (require web-server/servlet).  Note that I don't call anything from web-server/servlet -- it mere presence seems to be enough to sow untold confusion.


Excerpts from the output of raco exe --vv -o build/s s.ss:

Copying to #<path:build/s>
Getting #<path:/checkouts/me/projects/simbad-lod/src/s.rkt>
Getting #<path:/Data/LocalApplications/Racket/Racket v5.0/collects/racket/main.rkt>
Getting #<path:/Data/LocalApplications/Racket/Racket v5.0/collects/racket/base.rkt>
[...]
Getting #<path:/Data/LocalApplications/Racket/Racket v5.0/collects/web-server/dispatch/coercion.rkt>
Getting #<path:/Users/norman/Library/Racket/5.0/collects/rdf/librdf-extn.rkt>
 using extension: #<path:/Users/norman/Library/Racket/5.0/collects/rdf/compiled/native/i386-macosx/3m/librdf-extn_rkt.dylib>
Getting #<path:/Data/LocalApplications/Racket/Racket v5.0/collects/racket/runtime-config.rkt>
Recording extension at #<path:/Users/norman/Library/Racket/5.0/collects/rdf/compiled/native/i386-macosx/3m/librdf-extn_rkt.dylib>
Writing module from #<path:/Data/LocalApplications/Racket/Racket v5.0/collects/racket/private/stx.rkt>
[...]
Writing module from #<path:/Data/LocalApplications/Racket/Racket v5.0/collects/web-server/servlet.rkt>
Writing module from #<path:/checkouts/me/projects/simbad-lod/src/s.rkt>
Writing module from #<path:/Data/LocalApplications/Racket/Racket v5.0/collects/racket/runtime-config.rkt>
Setting command line



The way that the extension is built is:

make install
"/Data/LocalApplications/Racket/Racket v5.0/bin/raco" ctool --cc ++ccf -g ++ccf -I/Data/tools/librdf-2010-01-20/32bit/include --cgc  librdf_bindings.c
mv librdf_bindings.o build
"/Data/LocalApplications/Racket/Racket v5.0/bin/raco" ctool ++ldf -L/Data/tools/librdf-2010-01-20/32bit/lib ++ldf -lrdf --ld build/compiled/native/i386-macosx/3m/librdf-extn_rkt.dylib  build/librdf_bindings.o
cp -R build/compiled "/Users/norman/Library/Racket/5.0/collects"/rdf




I'm afraid I'm stumped.  Can anyone suggest what I've missed?

Best wishes,

Norman


-- 
Norman Gray  :  http://nxg.me.uk



Posted on the users mailing list.