| 1 |
= How to build stand-alone Gauche executable |
| 2 |
|
| 3 |
Building stand-alone executable is officially supported as of |
| 4 |
0.9.6. The static library `libgauche-static-0.9.a` is built |
| 5 |
by default. See |
| 6 |
link:http://practical-scheme.net/gauche/man/?l=en&p=Building%20standalone%20executables[Building standalone executables] |
| 7 |
section of the manual for the details. |
| 8 |
|
| 9 |
This file describes some advanced technical details. |
| 10 |
|
| 11 |
== Stripping down the size of the executable |
| 12 |
|
| 13 |
In order to create a static library that excludes certain |
| 14 |
modules, you can run `make static` under `src/` directory |
| 15 |
with the evironment variable `LIBGAUCHE_STATIC_EXCLUDES` |
| 16 |
set to list modules to be excluded: |
| 17 |
|
| 18 |
[source,console] |
| 19 |
---- |
| 20 |
$ LIBGAUCHE_STATIC_EXCLUDES=dbm.gdbm,os.windows make static |
| 21 |
---- |
| 22 |
|
| 23 |
|
| 24 |
== Using Gauche API from statically linked C applications |
| 25 |
|
| 26 |
If you want to call Gauche API from statically linked C app, |
| 27 |
you need slightly different initialization than the usual. |
| 28 |
Instead of calling `GC_INIT()` and `Scm_Init()`, you should do |
| 29 |
the following: |
| 30 |
|
| 31 |
1. include `gauche/static.h` _before_ `gauche.h` |
| 32 |
+ |
| 33 |
[source,c] |
| 34 |
---- |
| 35 |
#include <gauche/static.h> |
| 36 |
#include <gauche.h> |
| 37 |
---- |
| 38 |
|
| 39 |
2. call `SCM_INIT_STATIC()` from `main()`, instead of `GC_INIT()` |
| 40 |
and `Scm_INIT()`. |
| 41 |
+ |
| 42 |
[source,c] |
| 43 |
---- |
| 44 |
int main() { |
| 45 |
: |
| 46 |
SCM_INIT_STATIC(); |
| 47 |
: |
| 48 |
} |
| 49 |
---- |