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       --staticlib
55              Build a .a static library from object files.
56
57       --resources
58              Generate  a  .o file containing all the input resources. This is
59              useful when building with a PE compiler, since the  PE  binutils
60              cannot  handle  multiple resource files as input. For a standard
61              Unix build, the resource files are automatically  included  when
62              building  the  spec file, so there's no need for an intermediate
63              .o file.
64
65       --builtin
66              Mark a PE module as a Wine builtin module, by adding  the  "Wine
67              builtin DLL" signature string after the DOS header.
68
69       --fixup-ctors
70              Fixup constructors after a module has been built. This should be
71              done on the final .so module if its code contains  constructors,
72              to ensure that Wine has a chance to initialize the module before
73              the constructors are executed.
74

OPTIONS

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

SPEC FILE SYNTAX

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

AUTHORS

447       winebuild  has  been  worked on by many people over the years. The main
448       authors are Robert J. Amstadt, Alexandre Julliard, Martin  von  Loewis,
449       Ulrich  Weigand  and Eric Youngdale. Many other people have contributed
450       new features and bug fixes. For a complete list,  see  the  git  commit
451       logs.
452

BUGS

454       It  is  not yet possible to use a PE-format dll in an import specifica‐
455       tion; only Wine dlls can be imported.
456
457       Bugs can be reported on the Wine bug tracker https://bugs.winehq.org⟩.
458

AVAILABILITY

460       winebuild is part of the Wine distribution, which is available  through
461       WineHQ, the Wine development headquarters https://www.winehq.org/⟩.
462

SEE ALSO

464       wine(1), winegcc(1), wrc(1),
465       Wine documentation and support https://www.winehq.org/help⟩.
466
467
468
469Wine 6.3                         October 2005                     WINEBUILD(1)
Impressum