1mkbundle(mkbundle 1.0)                                  mkbundle(mkbundle 1.0)
2
3
4

NAME

6       mkbundle, mkbundle2 - Creates a bundled executable.
7

SYNOPSIS

9       mkbundle [options] assembly1 [assembly2 ...]
10

DESCRIPTION

12       mkbundle  generates  an  executable  program  that  will contain static
13       copies of the assemblies listed on the command line.  By  default  only
14       the  assemblies  specified  in the command line will be included in the
15       bundle.  To automatically include all of the  dependencies  referenced,
16       use the "--deps" command line option.
17
18       There are two modes of operation, one uses an existing Mono binary or a
19       server-hosted list of binaries and is enabled when you use  either  the
20       --cross, --sdk or the --runtime command line options.
21
22       An  older  mechanism creates a small C stub that links against the lib‐
23       mono library to produce a self-contained executable and  requires  a  C
24       compiler.   It is described in the "OLD EMBEDDING" section below.
25
26       For example, to create a bundle for hello world, use the following com‐
27       mand:
28
29            $ mkbundle -o hello --simple hello.exe
30
31
32       You can configure options to be passed to  the  Mono  runtime  directly
33       into  your  executable, for this, use the --options flag.  For example,
34       the following disables inlining, by passing  the  "-O=-inline"  command
35       line option to the embedded executable:
36
37            $ mkbundle -o hello --options -O=-inline --simple hello.exe
38
39
40       The simple version allows for cross-compiling, this requires a Mono
41       runtime to be installed in the ~/.mono/targets/TARGET/mono to be
42       available.   You can use the "--local-targets" to list all available
43       targets, and the "--cross" argument to specify the target, like this:
44
45            $ mkbundle --local-targets
46            Available targets:
47                 default   - Current System Mono
48                 4.4.0-macosx-x86
49                 4.4.0-debian-8-arm64
50            $ mkbundle --cross 4.4.0-debian-8-powerpc hello.exe -o hello-debian
51
52
53       The  above  will  bundle  your  native  library into hello-debian for a
54       Debian 8 system running on a PowerPC machine.
55
56       We provide pre-packages binaries for Mono  for  various  architectures,
57       which  allow you to cross compile, use the --list-targets to get a list
58       of all targets supported, and use the --fetch-target flag to retrieve a
59       target that you do not have installed, like this:
60
61            $ mkbundle --list-targets
62            Cross-compilation targets available:
63            4.4.0-linux-libc2.13-amd64
64            4.4.0-linux-libc2.13-armel
65            4.4.0-linux-libc2.13-armhf
66            4.4.0-linux-libc2.13-i386
67            4.4.0-macos-10.7-amd64
68            4.4.0-macos-10.7-i386
69            4.4.2-linux-libc2.13-amd64
70            4.4.2-linux-libc2.13-armel
71            4.4.2-linux-libc2.13-armhf
72            4.4.2-linux-libc2.13-i386
73            4.4.2-macos-10.7-amd64
74            4.4.2-macos-10.7-i386
75
76            $ mkbundle --fetch-target 4.4.2-macos-10.7-i386
77
78
79       And  then you can produce a binary that will run on 32-bit Mono on Mac‐
80       OS:
81
82            $ mkbundle --cross 4.4.2-macos-10.7-i386 hello.exe -o hello-macos
83
84
85       Downloaded targets are stored ~/.mono/targets directory.
86

OPTIONS

88       --config FILE
89              Specifies that a machine.config file must be  bundled  as  well.
90              Typically  this  is $prefix/etc/mono/1.0/machine.config or $pre‐
91              fix/etc/mono/2.0/machine.config depending on  the  profile  that
92              you are using (1.0 or 2.0)
93
94       --config-dir DIR
95              When  passed,  DIR  will be set for the MONO_CFG_DIR environment
96              variable
97
98       --cross target
99              Use this to request mkbundle generate a  cross-compiled  binary.
100              It Creates a bundle for the specified target platform.  The tar‐
101              get must be a directory in ~/.mono/targets/ that contains an SDK
102              installation  as produced by the mono-package-runtime tool.  You
103              can get a list of the precompiled versions of the runtime  using
104              --list-targets  and  you  can  fetch a specific target using the
105              --fetch-target command line option.
106
107              This flag is mutually exclusive with  --sdk  which  is  used  to
108              specify  an  absolute  path to resolve the Mono runtime from and
109              the --runtime option which is used  to  manually  construct  the
110              cross-platform package.
111
112       --deps This option will bundle all of the referenced assemblies for the
113              assemblies listed on the command line option.  This is useful to
114              distribute a self-contained image.
115
116       --env KEY=VALUE
117              Use  this to hardcode an environment variable at runtime for KEY
118              to be mapped to VALUE.   This is useful in scenarios  where  you
119              want  to  enable certain Mono runtime configuration options that
120              are controlled by environment variables.
121
122       --fetch-target target
123              Downloads a precompiled runtime for the  specified  target  from
124              the Mono distribution site.
125
126       --i18n encoding
127              Specified  which  encoding  tables  to ship with the executable.
128              By default, Mono ships the supporting I18N.dll assembly and  the
129              I18N.West.dll  assembly.   If your application will use the Sys‐
130              tem.Text.Encoding.GetEncoding with encodings other than the West
131              encodings, you should specify them here.
132
133              You  can  use  the  none  parameter  to request that no implicit
134              encodings should be bundled, including the supporting  I18N.dll,
135              use this option if you have ran a linker on your own.
136
137              You can use the all flag to bundle all available encodings.
138
139              Or  you  can  use a comma delimited list of the workds CJK, Mid‐
140              West, Other, Rare and West to specificy  which  encoding  assem‐
141              blies to distribute.
142
143       -L path
144              Adds  the  `path'  do the search list for assemblies.  The rules
145              are the same as for the compiler -lib: or -L flags.
146
147       --library [LIB,]PATH
148              Embeds the dynamic library file pointed to by `PATH' and option‐
149              ally  give it the name `LIB' into the bundled executable.   This
150              is used to ship native library dependencies that are unpacked at
151              startup and loaded from the runtime.
152
153       --lists-targets
154              Lists  all  of  the  available  local  cross compilation targets
155              available as  precompiled  binaries  on  the  Mono  distribution
156              server.
157
158       --local-targets
159              Lists all of the available local cross compilation targets.
160
161       --machine-config FILE
162              Uses the given FILE as the machine.config file for the generated
163              application.
164
165       --nodeps
166              This is the default: mkbundle will only include  the  assemblies
167              that  were  specified  on the command line to reduce the size of
168              the resulting image created.
169
170       -o filename
171              Places the output on `out'.  If the flag -c is  specified,  this
172              is the C host program.  If not, this contains the resulting exe‐
173              cutable.
174
175       --options OPTS
176              Since the resulting executable will be treated as  a  standalone
177              program,  you  can use this option to pass configuration options
178              to the Mono runtime and  bake  those  into  the  resulting  exe‐
179              cutable.  These options are specified as OPTS.
180
181              You  can use the above to configure options that you would typi‐
182              cally pass on the command line to Mono, before the main  program
183              is executed.
184
185              Additionally, users of your binary can still configure their own
186              options by setting the MONO_ENV_OPTIONS environment variable.
187
188       --sdk SDK_PATH
189              Use this flag to specify a path from which mkbundle will resolve
190              the Mono SDK from.   The SDK path should be the prefix path that
191              you used to configure a Mono installation.   And would typically
192              contain  files lik SDK_PATH/bin/mono , SDK_PATH/lib/mono/4.5 and
193              so on.
194
195              When this flag is specified, mkbundle will resolve the  runtime,
196              the  framework  libraries, unmanaged resources and configuration
197              files from the files located in this directory.
198
199              This flag is mutually exlusive with --cross
200
201       --target-server SERVER
202              By default the mkbundle tool will download from  a  Mono  server
203              the  target runtimes, you can specify a different server to pro‐
204              vide cross-compiled runtimes.
205

OLD EMBEDDING

207       The old embedding system compiles a small C stub that embeds the C code
208       and compiles the resulting executable using the system compiler.   This
209       requires both a working C compiler installation and only works to  bun‐
210       dle binaries for the current host.
211
212       The  feature  is  still available, but we recommend the simpler, faster
213       and more convenient new mode.
214
215       For example, to create a bundle for hello world, use the following com‐
216       mand:
217
218            $ mkbundle -o hello hello.exe
219
220       The  above  will  pull  hello.exe into a native program called "hello".
221       Notice that the produced image still contains the CIL image and no pre‐
222       compilation is done.
223
224       In  addition, it is possible to control whether mkbundle should compile
225       the resulting executable or not with the -c option.  This is useful  if
226       you  want  to link additional libraries or control the generated output
227       in more detail. For example, this could be used to link some  libraries
228       statically:
229
230            $ mkbundle -c -o host.c -oo bundles.o --deps hello.exe
231
232            $ cc host.c bundles.o /usr/lib/libmono.a -lc -lrt
233
234       You  may also use mkbundle to generate a bundle you can use when embed‐
235       ding the Mono runtime in a native application.  In that case, use  both
236       the -c and --nomain options.  The resulting host.c file will not have a
237       main() function.  Call mono_mkbundle_init() before initializing the JIT
238       in your code so that the bundled assemblies are available to the embed‐
239       ded runtime.
240

OLD EMBEDDING OPTIONS

242       These options can only be used instead of using the --cross,  --runtime
243       or --simple options.
244
245       -c     Produce the stub file, do not compile the resulting stub.
246
247       -oo filename
248              Specifies  the  name  to be used for the helper object file that
249              contains the bundle.
250
251       --keeptemp
252              By default mkbundle will delete the temporary files that it uses
253              to produce the bundle.  This option keeps the file around.
254
255       --nomain
256              With  the  -c  option,  generate  the host stub without a main()
257              function.
258
259       --static
260              By default mkbundle dynamically links to mono  and  glib.   This
261              option causes it to statically link instead.
262
263       -z     Compresses  the  assemblies  before  embedding.  This results in
264              smaller  executable  files,  but  increases  startup  time   and
265              requires zlib to be installed on the target system.
266

WINDOWS

268       If  you are using the old embedding on Windows systems, it it necessary
269       to have Unix-like toolchain to be installed for mkbundle to work.   You
270       can use cygwin's and install gcc, gcc-mingw and as packages.
271

ENVIRONMENT VARIABLES

273       AS     Assembler command. The default is "as".
274
275       CC     C  compiler  command.  The default is "cc" under Linux and "gcc"
276              under Windows.
277
278       MONO_BUNDLED_OPTIONS
279              Options to be passed to the bundled Mono runtime,  separated  by
280              spaces. See the mono(1) manual page or run mono --help.
281

FILES

283       This  program  will  load  referenced assemblies from the Mono assembly
284       cache.
285
286       Targets are loaded from ~/.mono/targets/TARGETNAME/mono
287

BUGS

289       The option "--static" is not supported under Windows when using the old
290       embedding.   Moreover,  a  full  cygwin environment containing at least
291       "gcc" and "as" is required for the build process.  The  generated  exe‐
292       cutable does not depend on cygwin.
293

MAILING LISTS

295       Visit    http://lists.ximian.com/mailman/listinfo/mono-devel-list   for
296       details.
297

WEB SITE

299       Visit: http://www.mono-project.com for details
300

SEE ALSO

302       mcs(1),mono(1),mono-config(5).
303
304
305
306
307
308                                                        mkbundle(mkbundle 1.0)
Impressum