1WINEBUILD(1)                Wine Developers Manual                WINEBUILD(1)
2
3
4

NAME

6       winebuild - Wine dll builder
7

SYNOPSIS

9       winebuild [options] [inputfile...]
10

DESCRIPTION

12       winebuild  generates  the  assembly files that are necessary to build a
13       Wine dll, which is basically a Win32 dll  encapsulated  inside  a  Unix
14       library.
15
16       winebuild  has  different  modes,  depending on what kind of file it is
17       asked to generate. The mode is specified by one  of  the  mode  options
18       specified below. In addition to the mode option, various other command-
19       line option can be specified, as described in the OPTIONS section.
20

MODE OPTIONS

22       You have to specify exactly one of the following options, depending  on
23       what you want winebuild to generate.
24
25       --dll  Build  an  assembly file from a .spec file (see SPEC FILE SYNTAX
26              for  details),  or  from  a  standard  Windows  .def  file.  The
27              .spec/.def  file  is  specified via the -E option. The resulting
28              file must be assembled and linked to the other object  files  to
29              build  a working Wine dll.  In this mode, the input files should
30              be the list of all object files that will  be  linked  into  the
31              final  dll,  to allow winebuild to get the list of all undefined
32              symbols that need to be imported from other dlls.
33
34       --exe  Build an assembly file for an executable. This is basically  the
35              same  as  the  --dll  mode  except  that  it  doesn't  require a
36              .spec/.def file as input, since an executable  need  not  export
37              functions. Some executables however do export functions, and for
38              those a .spec/.def file can be specified via the -E option.  The
39              executable is named from the .spec/.def file name if present, or
40              explicitly through the -F option. The  resulting  file  must  be
41              assembled  and linked to the other object files to build a work‐
42              ing Wine executable, and all the  other  object  files  must  be
43              listed as input files.
44
45       --def  Build  a .def file from a spec file. The .spec file is specified
46              via the -E option. This is used when building  dlls  with  a  PE
47              (Win32) compiler.
48
49       --implib
50              Build  a  .a  import library from a spec file. The .spec file is
51              specified via the -E option. If the output library name ends  in
52              .delay.a, a delayed import library is built.
53
54       --resources
55              Generate  a  .o file containing all the input resources. This is
56              useful when building with a PE compiler, since the  PE  binutils
57              cannot  handle  multiple resource files as input. For a standard
58              Unix build, the resource files are automatically  included  when
59              building  the  spec file, so there's no need for an intermediate
60              .o file.
61

OPTIONS

63       --as-cmd=as-command
64              Specify the command  to  use  to  compile  assembly  files;  the
65              default is as.
66
67       -b, --target=cpu-manufacturer[-kernel]-os
68              Specify  the target CPU and platform on which the generated code
69              will be built. The target specification is in the standard auto‐
70              conf format as returned by config.sub.
71
72       -B directory
73              Add  the  directory  to the search path for the various binutils
74              tools like as, nm and ld.
75
76       --cc-cmd=cc-command
77              Specify the C compiler to use to  compile  assembly  files;  the
78              default is to instead use the assembler specified with --as-cmd.
79
80       -d, --delay-lib=name
81              Set  the  delayed  import  mode for the specified library, which
82              must be one of  the  libraries  imported  with  the  -l  option.
83              Delayed  mode  means  that  the  library won't be loaded until a
84              function imported from it is actually called.
85
86       -D symbol
87              Ignored for compatibility with the C compiler.
88
89       -e, --entry=function
90              Specify the module entry point function; if not  specified,  the
91              default  is  DllMain  for dlls, and main for executables (if the
92              standard C main is not defined, WinMain is used  instead).  This
93              is only valid for Win32 modules.
94
95       -E, --export=filename
96              Specify  a  .spec  file (see SPEC FILE SYNTAX for details), or a
97              standard Windows .def file that defines the exports of  the  DLL
98              or executable that is being built.
99
100       --external-symbols
101              Allow  linking  to external symbols directly from the spec file.
102              Normally symbols exported by a dll have to be defined in the dll
103              itself;  this option makes it possible to use symbols defined in
104              another Unix library (for symbols defined in another dll, a for‐
105              ward specification must be used instead).
106
107       -f option
108              Specify  a  code  generation option. Currently -fPIC and -fasyn‐
109              chronous-unwind-tables are supported. Other options are  ignored
110              for compatibility with the C compiler.
111
112       --fake-module
113              Create  a fake PE module for a dll or exe, instead of the normal
114              assembly or object file. The PE module  contains  the  resources
115              for the module, but no executable code.
116
117       -F, --filename=filename
118              Set  the file name of the module. The default is to use the base
119              name of the spec file (without any extension).
120
121       -h, --help
122              Display a usage message and exit.
123
124       -H, --heap=size
125              Specify the size of the module local heap in bytes  (only  valid
126              for Win16 modules); default is no local heap.
127
128       -I directory
129              Ignored for compatibility with the C compiler.
130
131       -k, --kill-at
132              Remove the stdcall decorations from the symbol names in the gen‐
133              erated .def file. Only meaningful in --def mode.
134
135       -K flags
136              Ignored for compatibility with the C compiler.
137
138       --large-address-aware
139              Set a flag in the executable to  notify  the  loader  that  this
140              application supports address spaces larger than 2 gigabytes.
141
142       --ld-cmd=ld-command
143              Specify the command to use to link the object files; the default
144              is ld.
145
146       -L, --library-path=directory
147              Append the specified directory to the list of  directories  that
148              are searched for import libraries.
149
150       -l, --library=name
151              Import  the  specified library, looking for a corresponding lib‐
152              name.def file in the directories specified with the -L option.
153
154       -m16, -m32, -m64
155              Generate respectively 16-bit, 32-bit or 64-bit code.
156
157       -marm, -mthumb, -march=option, -mcpu=option, -mfpu=option, -mfloat-
158       abi=option
159              Set code generation options for the assembler.
160
161       -munix Build  a library that imports standard functions from the Unix C
162              library instead of the Windows runtime.
163
164       -M, --main-module=module
165              When building a 16-bit dll, set the name of its 32-bit  counter‐
166              part  to module. This is used to enforce that the load order for
167              the 16-bit dll matches that of the 32-bit one.
168
169       -N, --dll-name=dllname
170              Set the internal name of the module. It is only  used  in  Win16
171              modules.  The  default  is to use the base name of the spec file
172              (without any extension). This is used for KERNEL, since it lives
173              in KRNL386.EXE. It shouldn't be needed otherwise.
174
175       --nm-cmd=nm-command
176              Specify the command to use to get the list of undefined symbols;
177              the default is nm.
178
179       --nxcompat=yes|no
180              Specify whether the module is compatible with  no-exec  support.
181              The default is yes.
182
183       -o, --output=file
184              Set the name of the output file (default is standard output). If
185              the output file name ends in .o, the text output is  sent  to  a
186              temporary  file  that is then assembled to produce the specified
187              .o file.
188
189       -r, --res=rsrc.res
190              Load resources from the  specified  binary  resource  file.  The
191              rsrc.res  file  can be produced from a source resource file with
192              wrc(1) (or with a Windows resource compiler).
193              This option is only necessary  for  Win16  resource  files,  the
194              Win32  ones  can simply listed as input files and will automati‐
195              cally be handled correctly (though the -r option will also  work
196              for Win32 files).
197
198       --save-temps
199              Do  not delete the various temporary files that winebuild gener‐
200              ates.
201
202       --subsystem=subsystem[:major[.minor]]
203              Set the subsystem of the executable, which can  be  one  of  the
204              following:
205              console for a command line executable,
206              windows for a graphical executable,
207              native for a native-mode dll,
208              wince for a ce dll.
209              The  entry point of a command line executable is a normal C main
210              function. A wmain function can be used instead if you  need  the
211              argument  array  to  use Unicode strings. A graphical executable
212              has a WinMain entry point.
213              Optionally a major and minor subsystem version can also be spec‐
214              ified; the default subsystem version is 4.0.
215
216       -u, --undefined=symbol
217              Add  symbol  to  the list of undefined symbols when invoking the
218              linker. This makes it possible to force a specific module  of  a
219              static library to be included when resolving imports.
220
221       -v, --verbose
222              Display the various subcommands being invoked by winebuild.
223
224       --version
225              Display the program version and exit.
226
227       -w, --warnings
228              Turn on warnings.
229

SPEC FILE SYNTAX

231   General syntax
232       A  spec file should contain a list of ordinal declarations. The general
233       syntax is the following:
234
235       ordinal functype [flags] exportname ( [args...] ) [handler]
236       ordinal variable [flags] exportname ( [data...] )
237       ordinal extern [flags] exportname [symbolname]
238       ordinal stub [flags] exportname [ (args...) ]
239       ordinal equate [flags] exportname data
240       # comments
241
242       Declarations must fit on a single line, except if the end  of  line  is
243       escaped using a backslash character. The # character anywhere in a line
244       causes the rest of the line to be ignored as a comment.
245
246       ordinal specifies the ordinal number corresponding to the entry  point,
247       or '@' for automatic ordinal allocation (Win32 only).
248
249       flags  is  a series of optional flags, preceded by a '-' character. The
250       supported flags are:
251
252              -norelay
253                     The entry point  is  not  displayed  in  relay  debugging
254                     traces (Win32 only).
255
256              -noname
257                     The entry point will be exported by ordinal instead of by
258                     name. The name is still available for importing.
259
260              -ret16 The function returns a 16-bit value (Win16 only).
261
262              -ret64 The function returns a 64-bit value (Win32 only).
263
264              -register
265                     The function uses CPU register to pass arguments.
266
267              -private
268                     The function cannot be imported from other dlls,  it  can
269                     only be accessed through GetProcAddress.
270
271              -ordinal
272                     The entry point will be imported by ordinal instead of by
273                     name. The name is still exported.
274
275              -thiscall
276                     The function uses the thiscall calling convention  (first
277                     parameter in %ecx register on i386).
278
279              -fastcall
280                     The  function uses the fastcall calling convention (first
281                     two parameters in %ecx/%edx registers on i386).
282
283              -import
284                     The function is imported from another module. This can be
285                     used  instead of a forward specification when an applica‐
286                     tion expects to find the function's implementation inside
287                     the dll.
288
289              -arch=[!]cpu[,cpu]
290                     The  entry  point  is only available on the specified CPU
291                     architecture(s). The names  win32  and  win64  match  all
292                     32-bit  or  64-bit  CPU  architectures  respectively.  In
293                     16-bit dlls,  specifying  -arch=win32  causes  the  entry
294                     point  to  be  exported from the 32-bit wrapper module. A
295                     CPU name can be prefixed with ! to exclude only that spe‐
296                     cific architecture.
297
298   Function ordinals
299       Syntax:
300       ordinal functype [flags] exportname ( [args...] ) [handler]
301
302       This declaration defines a function entry point.  The prototype defined
303       by exportname ( [args...] ) specifies the name  available  for  dynamic
304       linking  and  the  format  of the arguments. '@' can be used instead of
305       exportname for ordinal-only exports.
306
307       functype should be one of:
308
309              stdcall
310                     for a normal Win32 function
311
312              pascal for a normal Win16 function
313
314              cdecl  for a Win16 or Win32 function using the C calling conven‐
315                     tion
316
317              varargs
318                     for a Win16 or Win32 function using the C calling conven‐
319                     tion with a variable number of arguments
320
321       args should be one or several of:
322
323              word   (16-bit unsigned value)
324
325              s_word (16-bit signed word)
326
327              long   (pointer-sized integer value)
328
329              int64  (64-bit integer value)
330
331              int128 (128-bit integer value)
332
333              float  (32-bit floating point value)
334
335              double (64-bit floating point value)
336
337              ptr    (linear pointer)
338
339              str    (linear pointer to a null-terminated ASCII string)
340
341              wstr   (linear pointer to a null-terminated Unicode string)
342
343              segptr (segmented pointer)
344
345              segstr (segmented pointer to a null-terminated ASCII string).
346
347              Note: The 16-bit and segmented pointer types are only valid  for
348                     Win16 functions.
349
350       handler  is  the name of the actual C function that will implement that
351       entry point in 32-bit mode. The handler can also be specified  as  dll‐
352       name.function  to define a forwarded function (one whose implementation
353       is in another dll). If handler is not specified, it is  assumed  to  be
354       identical to exportname.
355
356       This  first  example  defines  an entry point for the 32-bit GetFocus()
357       call:
358
359              @ stdcall GetFocus() GetFocus
360
361       This second example defines an entry point for  the  16-bit  CreateWin‐
362       dow() call (the ordinal 100 is just an example); it also shows how long
363       lines can be split using a backslash:
364
365              100 pascal CreateWindow(ptr ptr long s_word s_word s_word \
366                  s_word word word word ptr) WIN_CreateWindow
367
368       To declare a function using a variable number of arguments, specify the
369       function as varargs and declare it in the C file with a '...' parameter
370       for a Win32 function, or with an extra VA_LIST16 argument for  a  Win16
371       function.  See the wsprintf* functions in user.exe.spec and user32.spec
372       for an example.
373
374   Variable ordinals
375       Syntax:
376       ordinal variable [flags] exportname ( [data...] )
377
378       This declaration defines data storage as 32-bit words  at  the  ordinal
379       specified.   exportname will be the name available for dynamic linking.
380       data can be a decimal number or a hex number  preceded  by  "0x".   The
381       following  example defines the variable VariableA at ordinal 2 and con‐
382       taining 4 ints:
383
384              2 variable VariableA(-1 0xff 0 0)
385
386       This declaration only works in Win16 spec files. In  Win32  you  should
387       use extern instead (see below).
388
389   Extern ordinals
390       Syntax:
391       ordinal extern [flags] exportname [symbolname]
392
393       This declaration defines an entry that simply maps to a C symbol (vari‐
394       able or function). It only works in Win32 spec files.  exportname  will
395       point  to  the  symbol  symbolname  that must be defined in the C code.
396       Alternatively, it can be of the form  dllname.symbolname  to  define  a
397       forwarded  symbol (one whose implementation is in another dll). If sym‐
398       bolname is not specified, it is assumed to be identical to exportname.
399
400   Stub ordinals
401       Syntax:
402       ordinal stub [flags] exportname [ (args...) ]
403
404       This declaration defines a stub function. It makes the name and ordinal
405       available  for  dynamic  linking,  but will terminate execution with an
406       error message if the function is ever called.
407
408   Equate ordinals
409       Syntax:
410       ordinal equate [flags] exportname data
411
412       This declaration defines an ordinal as an absolute  value.   exportname
413       will  be the name available for dynamic linking.  data can be a decimal
414       number or a hex number preceded by "0x".
415

AUTHORS

417       winebuild has been worked on by many people over the  years.  The  main
418       authors  are  Robert J. Amstadt, Alexandre Julliard, Martin von Loewis,
419       Ulrich Weigand and Eric Youngdale. Many other people  have  contributed
420       new  features  and  bug  fixes. For a complete list, see the git commit
421       logs.
422

BUGS

424       It is not yet possible to use a PE-format dll in an  import  specifica‐
425       tion; only Wine dlls can be imported.
426
427       Bugs can be reported on the Wine bug tracker https://bugs.winehq.org⟩.
428

AVAILABILITY

430       winebuild  is part of the Wine distribution, which is available through
431       WineHQ, the Wine development headquarters https://www.winehq.org/⟩.
432

SEE ALSO

434       wine(1), winegcc(1), wrc(1),
435       Wine documentation and support https://www.winehq.org/help⟩.
436
437
438
439Wine 4.21                        October 2005                     WINEBUILD(1)
Impressum