1WINEBUILD(1) Wine Developers Manual WINEBUILD(1)
2
3
4
6 winebuild - Wine dll builder
7
9 winebuild [options] [inputfile...]
10
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
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
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 --cc-cmd=cc-command
73 Specify the C compiler to use to compile assembly files; the
74 default is to instead use the assembler specified with --as-cmd.
75
76 -d, --delay-lib=name
77 Set the delayed import mode for the specified library, which
78 must be one of the libraries imported with the -l option.
79 Delayed mode means that the library won't be loaded until a
80 function imported from it is actually called.
81
82 -D symbol
83 Ignored for compatibility with the C compiler.
84
85 -e, --entry=function
86 Specify the module entry point function; if not specified, the
87 default is DllMain for dlls, and main for executables (if the
88 standard C main is not defined, WinMain is used instead). This
89 is only valid for Win32 modules.
90
91 -E, --export=filename
92 Specify a .spec file (see SPEC FILE SYNTAX for details), or a
93 standard Windows .def file that defines the exports of the DLL
94 or executable that is being built.
95
96 --external-symbols
97 Allow linking to external symbols directly from the spec file.
98 Normally symbols exported by a dll have to be defined in the dll
99 itself; this option makes it possible to use symbols defined in
100 another Unix library (for symbols defined in another dll, a for‐
101 ward specification must be used instead).
102
103 -f option
104 Specify a code generation option. Currently -fPIC and -fasyn‐
105 chronous-unwind-tables are supported. Other options are ignored
106 for compatibility with the C compiler.
107
108 --fake-module
109 Create a fake PE module for a dll or exe, instead of the normal
110 assembly or object file. The PE module contains the resources
111 for the module, but no executable code.
112
113 -F, --filename=filename
114 Set the file name of the module. The default is to use the base
115 name of the spec file (without any extension).
116
117 -h, --help
118 Display a usage message and exit.
119
120 -H, --heap=size
121 Specify the size of the module local heap in bytes (only valid
122 for Win16 modules); default is no local heap.
123
124 -I directory
125 Ignored for compatibility with the C compiler.
126
127 -k, --kill-at
128 Remove the stdcall decorations from the symbol names in the gen‐
129 erated .def file. Only meaningful in --def mode.
130
131 -K flags
132 Ignored for compatibility with the C compiler.
133
134 --large-address-aware
135 Set a flag in the executable to notify the loader that this
136 application supports address spaces larger than 2 gigabytes.
137
138 --ld-cmd=ld-command
139 Specify the command to use to link the object files; the default
140 is ld.
141
142 -L, --library-path=directory
143 Append the specified directory to the list of directories that
144 are searched for import libraries.
145
146 -l, --library=name
147 Import the specified library, looking for a corresponding lib‐
148 name.def file in the directories specified with the -L option.
149
150 -m16, -m32, -m64
151 Generate respectively 16-bit, 32-bit or 64-bit code.
152
153 -marm, -mthumb, -march=option, -mcpu=option, -mfpu=option, -mfloat-
154 abi=option
155 Set code generation options for the assembler.
156
157 -M, --main-module=module
158 When building a 16-bit dll, set the name of its 32-bit counter‐
159 part to module. This is used to enforce that the load order for
160 the 16-bit dll matches that of the 32-bit one.
161
162 -N, --dll-name=dllname
163 Set the internal name of the module. It is only used in Win16
164 modules. The default is to use the base name of the spec file
165 (without any extension). This is used for KERNEL, since it lives
166 in KRNL386.EXE. It shouldn't be needed otherwise.
167
168 --nm-cmd=nm-command
169 Specify the command to use to get the list of undefined symbols;
170 the default is nm.
171
172 --nxcompat=yes|no
173 Specify whether the module is compatible with no-exec support.
174 The default is yes.
175
176 -o, --output=file
177 Set the name of the output file (default is standard output). If
178 the output file name ends in .o, the text output is sent to a
179 temporary file that is then assembled to produce the specified
180 .o file.
181
182 -r, --res=rsrc.res
183 Load resources from the specified binary resource file. The
184 rsrc.res file can be produced from a source resource file with
185 wrc(1) (or with a Windows resource compiler).
186 This option is only necessary for Win16 resource files, the
187 Win32 ones can simply listed as input files and will automati‐
188 cally be handled correctly (though the -r option will also work
189 for Win32 files).
190
191 --save-temps
192 Do not delete the various temporary files that winebuild gener‐
193 ates.
194
195 --subsystem=subsystem[:major[.minor]]
196 Set the subsystem of the executable, which can be one of the
197 following:
198 console for a command line executable,
199 windows for a graphical executable,
200 native for a native-mode dll,
201 wince for a ce dll.
202 The entry point of a command line executable is a normal C main
203 function. A wmain function can be used instead if you need the
204 argument array to use Unicode strings. A graphical executable
205 has a WinMain entry point.
206 Optionally a major and minor subsystem version can also be spec‐
207 ified; the default subsystem version is 4.0.
208
209 -u, --undefined=symbol
210 Add symbol to the list of undefined symbols when invoking the
211 linker. This makes it possible to force a specific module of a
212 static library to be included when resolving imports.
213
214 -v, --verbose
215 Display the various subcommands being invoked by winebuild.
216
217 --version
218 Display the program version and exit.
219
220 -w, --warnings
221 Turn on warnings.
222
224 General syntax
225 A spec file should contain a list of ordinal declarations. The general
226 syntax is the following:
227
228 ordinal functype [flags] exportname ( [args...] ) [handler]
229 ordinal variable [flags] exportname ( [data...] )
230 ordinal extern [flags] exportname [symbolname]
231 ordinal stub [flags] exportname [ (args...) ]
232 ordinal equate [flags] exportname data
233 # comments
234
235 Declarations must fit on a single line, except if the end of line is
236 escaped using a backslash character. The # character anywhere in a line
237 causes the rest of the line to be ignored as a comment.
238
239 ordinal specifies the ordinal number corresponding to the entry point,
240 or '@' for automatic ordinal allocation (Win32 only).
241
242 flags is a series of optional flags, preceded by a '-' character. The
243 supported flags are:
244
245 -norelay
246 The entry point is not displayed in relay debugging
247 traces (Win32 only).
248
249 -noname
250 The entry point will be exported by ordinal instead of by
251 name. The name is still available for importing.
252
253 -ret16 The function returns a 16-bit value (Win16 only).
254
255 -ret64 The function returns a 64-bit value (Win32 only).
256
257 -register
258 The function uses CPU register to pass arguments.
259
260 -private
261 The function cannot be imported from other dlls, it can
262 only be accessed through GetProcAddress.
263
264 -ordinal
265 The entry point will be imported by ordinal instead of by
266 name. The name is still exported.
267
268 -thiscall
269 The function uses the thiscall calling convention (first
270 parameter in %ecx register on i386).
271
272 -fastcall
273 The function uses the fastcall calling convention (first
274 two parameters in %ecx/%edx registers on i386).
275
276 -arch=cpu[,cpu]
277 The entry point is only available on the specified CPU architec‐
278 ture(s). The names win32 and win64 match all 32-bit or 64-bit
279 CPU architectures respectively. In 16-bit dlls, specifying
280 -arch=win32 causes the entry point to be exported from the
281 32-bit wrapper module.
282
283 Function ordinals
284 Syntax:
285 ordinal functype [flags] exportname ( [args...] ) [handler]
286
287 This declaration defines a function entry point. The prototype defined
288 by exportname ( [args...] ) specifies the name available for dynamic
289 linking and the format of the arguments. '@' can be used instead of
290 exportname for ordinal-only exports.
291
292 functype should be one of:
293
294 stdcall
295 for a normal Win32 function
296
297 pascal for a normal Win16 function
298
299 cdecl for a Win16 or Win32 function using the C calling conven‐
300 tion
301
302 varargs
303 for a Win16 or Win32 function using the C calling conven‐
304 tion with a variable number of arguments
305
306 args should be one or several of:
307
308 word (16-bit unsigned value)
309
310 s_word (16-bit signed word)
311
312 long (pointer-sized integer value)
313
314 int64 (64-bit integer value)
315
316 int128 (128-bit integer value)
317
318 float (32-bit floating point value)
319
320 double (64-bit floating point value)
321
322 ptr (linear pointer)
323
324 str (linear pointer to a null-terminated ASCII string)
325
326 wstr (linear pointer to a null-terminated Unicode string)
327
328 segptr (segmented pointer)
329
330 segstr (segmented pointer to a null-terminated ASCII string).
331
332 Note: The 16-bit and segmented pointer types are only valid for
333 Win16 functions.
334
335 handler is the name of the actual C function that will implement that
336 entry point in 32-bit mode. The handler can also be specified as dll‐
337 name.function to define a forwarded function (one whose implementation
338 is in another dll). If handler is not specified, it is assumed to be
339 identical to exportname.
340
341 This first example defines an entry point for the 32-bit GetFocus()
342 call:
343
344 @ stdcall GetFocus() GetFocus
345
346 This second example defines an entry point for the 16-bit CreateWin‐
347 dow() call (the ordinal 100 is just an example); it also shows how long
348 lines can be split using a backslash:
349
350 100 pascal CreateWindow(ptr ptr long s_word s_word s_word \
351 s_word word word word ptr) WIN_CreateWindow
352
353 To declare a function using a variable number of arguments, specify the
354 function as varargs and declare it in the C file with a '...' parameter
355 for a Win32 function, or with an extra VA_LIST16 argument for a Win16
356 function. See the wsprintf* functions in user.exe.spec and user32.spec
357 for an example.
358
359 Variable ordinals
360 Syntax:
361 ordinal variable [flags] exportname ( [data...] )
362
363 This declaration defines data storage as 32-bit words at the ordinal
364 specified. exportname will be the name available for dynamic linking.
365 data can be a decimal number or a hex number preceded by "0x". The
366 following example defines the variable VariableA at ordinal 2 and con‐
367 taining 4 ints:
368
369 2 variable VariableA(-1 0xff 0 0)
370
371 This declaration only works in Win16 spec files. In Win32 you should
372 use extern instead (see below).
373
374 Extern ordinals
375 Syntax:
376 ordinal extern [flags] exportname [symbolname]
377
378 This declaration defines an entry that simply maps to a C symbol (vari‐
379 able or function). It only works in Win32 spec files. exportname will
380 point to the symbol symbolname that must be defined in the C code.
381 Alternatively, it can be of the form dllname.symbolname to define a
382 forwarded symbol (one whose implementation is in another dll). If sym‐
383 bolname is not specified, it is assumed to be identical to exportname.
384
385 Stub ordinals
386 Syntax:
387 ordinal stub [flags] exportname [ (args...) ]
388
389 This declaration defines a stub function. It makes the name and ordinal
390 available for dynamic linking, but will terminate execution with an
391 error message if the function is ever called.
392
393 Equate ordinals
394 Syntax:
395 ordinal equate [flags] exportname data
396
397 This declaration defines an ordinal as an absolute value. exportname
398 will be the name available for dynamic linking. data can be a decimal
399 number or a hex number preceded by "0x".
400
402 winebuild has been worked on by many people over the years. The main
403 authors are Robert J. Amstadt, Alexandre Julliard, Martin von Loewis,
404 Ulrich Weigand and Eric Youngdale. Many other people have contributed
405 new features and bug fixes. For a complete list, see the git commit
406 logs.
407
409 It is not yet possible to use a PE-format dll in an import specifica‐
410 tion; only Wine dlls can be imported.
411
412 Bugs can be reported on the Wine bug tracker ⟨https://bugs.winehq.org⟩.
413
415 winebuild is part of the Wine distribution, which is available through
416 WineHQ, the Wine development headquarters ⟨https://www.winehq.org/⟩.
417
419 wine(1), winegcc(1), wrc(1),
420 Wine documentation and support ⟨https://www.winehq.org/help⟩.
421
422
423
424Wine 4.9 October 2005 WINEBUILD(1)