On Wed, Nov 21, 2012 at 02:13:39PM -0700, Matt Gushee wrote: > I think what I want to do is to load shared libraries containing > modules into compiled code.
[...snip...] > And here's what happens when I try to work with them: > > $ csc -dynamic a.scm > $ csc -dynamic b.scm > $ csc -dynamic c.scm > $ csc -dynamic d.scm > $ csi > > CHICKEN > (c)2008-2012 The Chicken Team > (c)2000-2007 Felix L. Winkelmann > Version 4.8.0 (rev 0db1908) > linux-unix-gnu-x86 [ manyargs dload ptables ] > compiled 2012-09-24 on debian (Linux) > > ... [ loading ~/.csirc and various eggs ] ... > > csi> (load "ab.scm") > ; loading ab.scm ... > ; loading a.so ... > ; loading b.so ... > Ay, what's 'appening? > 2B or not 2B? > csi> (load "cd.scm") > ; loading cd.scm ... > ; loading c.so ... > ; loading d.so ... > See Spot run. > Defenestrate depraved demons. > csi> > $ csc ab.scm > $ ./ab > Ay, what's 'appening? > 2B or not 2B? > $ csc cd.scm > > Syntax error (import): cannot import from undefined module > > c That's because you didn't emit any import files. You'll need to use csc -j c c.scm to emit file c.import.scm, then compile that. When you then compile a file that requires these modules, it will try to load this import file, that informs the compiler about the modules that existed in the source code. The reason this is required is that a compiled file no longer has the meta-information about what modules are inside it and what they export. This allows for separate compilation without having to load (and execute) the entire library just to get the module info. This again allows for easier cross-compilation, for example (because you obviously can't load the library emitted for the foreign platform). It works in the interpreter because the entire library _is_ read and evaluated, declaring the module in the process. This stuff is documented here: http://wiki.call-cc.org/man/4/Modules > By the way, in addition to 'load-relative', I've also tried loading > the libs by means of 'require' (with and without the so-name), 'load', > and 'require-library'. In no case have I managed to compile a unit that > loads a library containing a module. That's because all of those still require the import library to be present. Hope this helps! Cheers, Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth _______________________________________________ Chicken-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-users
