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       -munix Build  a library that imports standard functions from the Unix C
175              library instead of the Windows runtime.
176
177       -M, --main-module=module
178              When building a 16-bit dll, set the name of its 32-bit  counter‐
179              part  to module. This is used to enforce that the load order for
180              the 16-bit dll matches that of the 32-bit one.
181
182       -N, --dll-name=dllname
183              Set the internal name of the module. It is only  used  in  Win16
184              modules.  The  default  is to use the base name of the spec file
185              (without any extension). This is used for KERNEL, since it lives
186              in KRNL386.EXE. It shouldn't be needed otherwise.
187
188       --nm-cmd=nm-command
189              Specify the command to use to get the list of undefined symbols;
190              the default is nm.
191
192       --nxcompat=yes|no
193              Specify whether the module is compatible with  no-exec  support.
194              The default is yes.
195
196       -o, --output=file
197              Set the name of the output file (default is standard output). If
198              the output file name ends in .o, the text output is  sent  to  a
199              temporary  file  that is then assembled to produce the specified
200              .o file.
201
202       -r, --res=rsrc.res
203              Load resources from the  specified  binary  resource  file.  The
204              rsrc.res  file  can be produced from a source resource file with
205              wrc(1) (or with a Windows resource compiler).
206              This option is only necessary  for  Win16  resource  files,  the
207              Win32  ones  can simply listed as input files and will automati‐
208              cally be handled correctly (though the -r option will also  work
209              for Win32 files).
210
211       --save-temps
212              Do  not delete the various temporary files that winebuild gener‐
213              ates.
214
215       --subsystem=subsystem[:major[.minor]]
216              Set the subsystem of the executable, which can  be  one  of  the
217              following:
218              console for a command line executable,
219              windows for a graphical executable,
220              native for a native-mode dll,
221              wince for a ce dll.
222              The  entry point of a command line executable is a normal C main
223              function. A wmain function can be used instead if you  need  the
224              argument  array  to  use Unicode strings. A graphical executable
225              has a WinMain entry point.
226              Optionally a major and minor subsystem version can also be spec‐
227              ified; the default subsystem version is 4.0.
228
229       -u, --undefined=symbol
230              Add  symbol  to  the list of undefined symbols when invoking the
231              linker. This makes it possible to force a specific module  of  a
232              static library to be included when resolving imports.
233
234       -v, --verbose
235              Display the various subcommands being invoked by winebuild.
236
237       --version
238              Display the program version and exit.
239
240       -w, --warnings
241              Turn on warnings.
242

SPEC FILE SYNTAX

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

AUTHORS

430       winebuild has been worked on by many people over the  years.  The  main
431       authors  are  Robert J. Amstadt, Alexandre Julliard, Martin von Loewis,
432       Ulrich Weigand and Eric Youngdale. Many other people  have  contributed
433       new  features  and  bug  fixes. For a complete list, see the git commit
434       logs.
435

BUGS

437       It is not yet possible to use a PE-format dll in an  import  specifica‐
438       tion; only Wine dlls can be imported.
439
440       Bugs can be reported on the Wine bug tracker https://bugs.winehq.org⟩.
441

AVAILABILITY

443       winebuild  is part of the Wine distribution, which is available through
444       WineHQ, the Wine development headquarters https://www.winehq.org/⟩.
445

SEE ALSO

447       wine(1), winegcc(1), wrc(1),
448       Wine documentation and support https://www.winehq.org/help⟩.
449
450
451
452Wine 5.7                         October 2005                     WINEBUILD(1)
Impressum