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

SPEC FILE SYNTAX

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

AUTHORS

473       winebuild  has  been  worked on by many people over the years. The main
474       authors are Robert J. Amstadt, Alexandre Julliard, Martin  von  Loewis,
475       Ulrich  Weigand  and Eric Youngdale. Many other people have contributed
476       new features and bug fixes. For a complete list,  see  the  git  commit
477       logs.
478

BUGS

480       It  is  not yet possible to use a PE-format dll in an import specifica‐
481       tion; only Wine dlls can be imported.
482
483       Bugs can be reported on the Wine bug tracker https://bugs.winehq.org⟩.
484

AVAILABILITY

486       winebuild is part of the Wine distribution, which is available  through
487       WineHQ, the Wine development headquarters https://www.winehq.org/⟩.
488

SEE ALSO

490       wine(1), winegcc(1), wrc(1),
491       Wine documentation and support https://www.winehq.org/help⟩.
492
493
494
495Wine 7.12                        October 2005                     WINEBUILD(1)
Impressum