I am trying to create an executable in racket that is dynamically linked. Currently my hello world program compiles to 4MB executable. Here it is:
#!/usr/bin/env racket
#lang racket
(define (extract str)
(substring str 4 7))
(print (extract "the cat out of the bag"))
I compile it using
raco exe first.rkt
And the resulting executable is 4+ MB. So, clearly, it is statically linking the racket libraries.
-- EDIT ---
Here is the launcher code:
#lang racket
(require launcher/launcher)
(require racket/runtime-path)
(define-runtime-path prog-path "first.rkt")
(make-racket-launcher (list (path->string prog-path))
"first"
'())
It just needs to put in a separate file and executed with
racket <launch-file>.rkt
The output of raco exe
is meant to statically include its required modules, so it may not be what you want. Have you looked at the launcher library? It'll make an exe that includes nothing but the absolute minimum to launch your program on your local installation.
Alternatively, choose a smaller language, like #lang racket/base
, which should produce smaller executables since it doesn't link to as many modules.
Finally, if you are on a Unix-based system, the program should already act as an executable if its executable bit (x) has been set, since you have already added the #!/usr/bin/env
racket line at the top. This assumes that your Racket is in PATH. See http://docs.racket-lang.org/guide/scripts.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With