[plt-scheme] Odd difference between standlone program and compiled version

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Nov 26 23:56:47 EST 2006

At Sun, 26 Nov 2006 14:09:41 -0800, Eric Hanchrow wrote:
> Now compile it to create a standalone executable, and run that:
> 
>     $ mzc --gui-exe repro repro.ss
>     mzc version 360.2, Copyright (c) 2004-2006 PLT Scheme Inc.
>      [output to "repro"]
>     $ DISPLAY=:0 ./repro
>     collection-path: collection not found: #<path:games/cards> in any of: ()
> 
>      === context ===
>     cloop
>     #f::353: loop
> 
> Why is the behavior different?

The "cards.ss" module loads images at run time from subdirectories of
the "cards" collection.

One solution is for "cards.ss" to use `include-bitmap', but that's a
lot of images that I'm reluctant to duplicate in compiled code. Maybe
one day we'll be able to write something like `(require "img.png")'.

Another possible solution is for the "cards.ss" module to somehow
declare the dependency on dynamically-loaded files, so that `mzc
--exe-dir' can automatically include them in a distribution. That's not
in place, obviously.

For now, you can work around the problem by assembling the images
manually, and then tell `mzc --exe-dir' to include them in the package.
For example:

  cd /tmp
  mkdir -p rcollects/games/cards
  cp -r <install-dir>/collects/games/cards/hicolor rcollects/games/cards
  cp -r <install-dir>/collects/games/cards/locolor rcollects/games/cards
  mzc --gui-exe repro repro.ss
  mzc --exe-dir repro-pkg ++collects-copy rcollects repro

Below is the same thing in Scheme code, which has the potential
advantage that it works on all platforms and you don't have to insert
<install-dir> or adjust the executable suffix.

Matthew

----------------------------------------

(require (lib "embed.ss" "compiler")
         (lib "distribute.ss" "compiler")
         (lib "file.ss"))

(define tmp-dir (find-system-path 'temp-dir))

(define tmp-app 
  (build-path tmp-dir
              (embedding-executable-add-suffix "repro" #t)))

(create-embedding-executable tmp-app
                             #:modules '((#f "repro.ss"))
                             #:cmdline '("-Zmvqe" "(require repro)")
                             #:mred? #t)

(let ([cards-dir (build-path tmp-dir "rcollects" "games" "cards")])
  (make-directory* cards-dir)
  (copy-directory/files (collection-path "games" "cards" "hicolor")
                        (build-path cards-dir "hicolor"))
  (copy-directory/files (collection-path "games" "cards" "locolor")
                        (build-path cards-dir "locolor")))

(assemble-distribution "repro-pkg"
                       (list tmp-app)
                       #:copy-collects
                       (list (build-path tmp-dir "rcollects")))



Posted on the users mailing list.