WINEBUILD(1)
π WINEBUILD(1) π
Wine Developers Manual Β· the dll-builder bestie of your dreams π β¨
π NAME π
winebuild β Wine dll builder π οΈπ
π SYNOPSIS π
winebuild [options] [inputfile...]
π¦ DESCRIPTION π¦
okay so real talk: winebuild is the icon that generates the assembly files you need to build a Wine dll. and what even is a Wine dll, you ask? it's basically a Win32 dll all cozy and encapsulated inside a Unix library. yes bestie, it's giving fusion cuisine π
winebuild has a bunch of different modes, and which one you get depends on what kind of file you're asking it to generate. you pick the mode with one of the mode options listed below β no cap. and on top of the mode option, you can also pass a whole pile of other command-line options, all described in the OPTIONS section. slay β¨
π MODE OPTIONS π
bestie, listen. you have to specify exactly one of these. not zero, not two. exactly one. it's giving monogamy π
--dllβ builds an assembly file from a.specfile (peep SPEC FILE SYNTAX for the deets), or from a standard Windows.deffile. the.spec/.deffile gets handed over via the-Eoption. the resulting file then has to be assembled and linked to the other object files to build a working Wine dll. in this mode, the input files should be the list of all object files that'll be linked into the final dll β that's howwinebuildgets the list of all the undefined symbols that need to be imported from other dlls π--exeβ builds an assembly file for an executable. it's basically the same as--dllmode, except it does not require a.spec/.deffile as input, since an executable doesn't have to export functions. but some executables DO export functions, and for those you can specify a.spec/.deffile via the-Eoption. the executable gets its name from the.spec/.deffile name if one is present, or explicitly through the-Foption. the resulting file must be assembled and linked to the other object files to build a working Wine executable, and all the other object files must be listed as input files π--defβ builds a.deffile from a spec file. the.specfile comes in via the-Eoption. this is what you use when building dlls with a PE (Win32) compiler π§--implibβ builds a.aimport library from a spec file. the.specfile is specified via the-Eoption. and ooh, plot twist: if the output library name ends in.delay.a, then a delayed import library is built instead πΈ--staticlibβ builds a.astatic library from object files. simple. clean. iconic β¨--resourcesβ generates a.ofile containing all the input resources. super useful when building with a PE compiler, because the PE binutils literally cannot handle multiple resource files as input (rude). for a standard Unix build though, the resource files get automatically included when building the spec file, so there's no need for an intermediate.ofile π«--builtinβ marks a PE module as a Wine builtin module, by adding the"Wine builtin DLL"signature string right after the DOS header. branding, but make it binary π--fixup-ctorsβ fixup constructors after a module has been built. you should do this on the final.somodule if its code contains constructors, to make sure Wine has a chance to initialize the module before the constructors get executed. order matters, bestie π«Ά
β¨ OPTIONS β¨
--as-cmd=as-commandβ pick the command used to compile assembly files; the default isasπ οΈ-b,--target=cpu-manufacturer[-kernel]-osβ set the target CPU and platform the generated code will be built on. the target spec is in the standard autoconf format, exactly like whatconfig.subreturns π―-Bdirectory β add directory to the search path for the various binutils tools likeas,nmandldπ--cc-cmd=cc-commandβ specify the C compiler to use for compiling assembly files; the default is to instead use the assembler specified with--as-cmdπ§°--data-onlyβ build a module that contains only data and resources and no executable code. with this option,winebuilddirectly outputs a PE file instead of an assembly or object file π¦-d,--delay-lib=nameβ set the delayed import mode for the specified library, which has to be one of the libraries imported with the-loption. delayed mode means the library won't be loaded until a function imported from it is actually called. lazy loading, but make it intentional π΄β¨-Dsymbol β ignored, for compatibility with the C compiler π-e,--entry=functionβ specify the module entry point function. if you don't, the default isDllMainfor dlls andmainfor executables (and if the standard Cmainisn't defined,WinMainis used instead). this is only valid for Win32 modules πͺ-E,--export=filenameβ specify a.specfile (see SPEC FILE SYNTAX for details), or a standard Windows.deffile that defines the exports of the DLL or executable being built π€--external-symbolsβ allow linking to external symbols directly from the spec file. normally, symbols exported by a dll have to be defined in the dll itself; this option makes it possible to use symbols defined in another Unix library. (and for symbols defined in another dll, you have to use a forward specification instead β no shortcuts bestie) π-foption β specify a code generation option. right now-fPICand-fasynchronous-unwind-tablesare supported. other options are ignored for compatibility with the C compiler π--fake-moduleβ create a fake PE module for a dll or exe, instead of the normal assembly or object file. the PE module contains the resources for the module, but no executable code π-F,--filename=filenameβ set the file name of the module. the default is to use the base name of the spec file (without any extension) π-h,--helpβ display a usage message and exit. classic π«Ά-H,--heap=sizeβ specify the size of the module local heap in bytes (only valid for Win16 modules); default is no local heap π§Ί-Idirectory β ignored, for compatibility with the C compiler π-k,--kill-atβ remove the stdcall decorations from the symbol names in the generated.deffile. only meaningful in--defmode βοΈ-Kflags β ignored, for compatibility with the C compiler π--large-address-awareβ set a flag in the executable to notify the loader that this application supports address spaces larger than 2 gigabytes π--ld-cmd=ld-commandβ specify the command to use to link the object files; the default isldπ-m16,-m32,-m64β generate respectively 16-bit, 32-bit or 64-bit code π’-march=option,-mcpu=option,-mfpu=optionβ set code generation options for the assembler ποΈ-mno-cygwinβ build a library that uses the Windows runtime instead of the Unix C library πͺ-M,--main-module=moduleβ when building a 16-bit dll, set the name of its 32-bit counterpart to module. this is used to enforce that the load order for the 16-bit dll matches that of the 32-bit one π§¬-N,--dll-name=dllnameβ set the internal name of the module. it's only used in Win16 modules. the default is to use the base name of the spec file (without any extension). this is used forKERNEL, since it lives inKRNL386.EXE. it shouldn't be needed otherwise π--nm-cmd=nm-commandβ specify the command used to get the list of undefined symbols; the default isnmπ--nxcompat=yes|noβ specify whether the module is compatible with no-exec support. the default isyesπ‘οΈ-o,--output=fileβ set the name of the output file (default is standard output). and here's the cute part: if the output file name ends in.o, the text output gets sent to a temporary file that's then assembled to produce the specified.ofile π--prefer-nativeβ specify that the native DLL should be preferred if it's available at run time. you can use this on modules that are mostly unimplemented π³οΈ-r,--res=rsrc.resβ load resources from the specified binary resource file. thersrc.resfile can be produced from a source resource file withwrc(1)(or with a Windows resource compiler). this option is only necessary for Win16 resource files β the Win32 ones can simply be listed as input files and will automatically be handled correctly (though the-roption will also work for Win32 files) π--safesehβ mark object files as SEH compatible π¦Ί--save-tempsβ do not delete the various temporary files thatwinebuildgenerates. keepsakes π--subsystem=subsystem[:major[.minor]]β set the subsystem of the executable, which can be one of these:consolefor a command line executable,windowsfor a graphical executable,nativefor a native-mode dll,wincefor a ce dll.
the entry point of a command line executable is a normal C main function. a wmain function can be used instead if you need the argument array to use Unicode strings. a graphical executable has a WinMain entry point. optionally, a major and minor subsystem version can also be specified; the default subsystem version is 4.0 π’
--syscall-table=idβ set the system call table id, between0and3. the default is0, the ntdll syscall table. only useful in modules that define syscall entry points π-u,--undefined=symbolβ add symbol to the list of undefined symbols when invoking the linker. this makes it possible to force a specific module of a static library to be included when resolving imports πͺ-v,--verboseβ display the various subcommands being invoked bywinebuild. yap mode, but productive π£οΈ--versionβ display the program version and exit π·οΈ-w,--warningsβ turn on warnings β οΈ--without-dlltoolβ generate import library without usingdlltoolπ«π§°
π SPEC FILE SYNTAX π
okay bestie this is the part where it gets juicy β this is literally where you tell winebuild what your dll is even made of. no cap, it's giving "write the blueprint of your whole library in plain text". obsessed.
β¨ General syntax β¨
A spec file should contain a list of ordinal declarations. The general syntax is the following:
ordinal functype [flags] exportname ( [args...] ) [handler]
ordinal variable [flags] exportname ( [data...] )
ordinal extern [flags] exportname [symbolname]
ordinal stub [flags] exportname [ (args...) ]
ordinal equate [flags] exportname data
# comments
Declarations must fit on a single line, except if the end of line is escaped using a backslash character. The # character anywhere in a line causes the rest of the line to be ignored as a comment. π
ordinal specifies the ordinal number corresponding to the entry point, or '@' for automatic ordinal allocation (Win32 only).
flags is a series of optional flags, preceded by a '-' character. The supported flags are:
-norelayβ the entry point is not displayed in relay debugging traces (Win32 only). it's shy, leave it alone π«Ά-nonameβ the entry point will be exported by ordinal instead of by name. The name is still available for importing.-ret16β the function returns a 16-bit value (Win16 only).-ret64β the function returns a 64-bit value (Win32 only).-registerβ the function uses CPU register to pass arguments.-privateβ the function cannot be imported from other dlls, it can only be accessed throughGetProcAddress. π-ordinalβ the entry point will be imported by ordinal instead of by name. The name is still exported.-thiscallβ the function uses thethiscallcalling convention (first parameter in%ecxregister on i386).-fastcallβ the function uses thefastcallcalling convention (first two parameters in%ecx/%edxregisters on i386).-syscallβ the function is an NT system call. A system call thunk will be generated, and the actual function will be called by the__wine_syscall_dispatcherfunction that will be generated on the Unix library side. π₯-importβ the function is imported from another module. This can be used instead of a forward specification when an application expects to find the function's implementation inside the dll.-arch=[!]cpu[,cpu]β the entry point is only available on the specified CPU architecture(s). The nameswin32andwin64match all 32-bit or 64-bit CPU architectures respectively. In 16-bit dlls, specifying-arch=win32causes the entry point to be exported from the 32-bit wrapper module. A CPU name can be prefixed with!to exclude only that specific architecture. π¦
π Function ordinals π
Syntax:
ordinal functype [flags] exportname ( [args...] ) [handler]
This declaration defines a function entry point. The prototype defined by exportname ( [args...] ) specifies the name available for dynamic linking and the format of the arguments. '@' can be used instead of exportname for ordinal-only exports.
functype should be one of:
stdcallβ for a normal Win32 functionpascalβ for a normal Win16 functioncdeclβ for a Win16 or Win32 function using the C calling conventionvarargsβ for a Win16 or Win32 function using the C calling convention with a variable number of arguments
args should be one or several of:
wordβ (16-bit unsigned value)s_wordβ (16-bit signed word)longβ (pointer-sized integer value)int64β (64-bit integer value)int128β (128-bit integer value)floatβ (32-bit floating point value)doubleβ (64-bit floating point value)ptrβ (linear pointer)strβ (linear pointer to a null-terminated ASCII string)wstrβ (linear pointer to a null-terminated Unicode string)segptrβ (segmented pointer)segstrβ (segmented pointer to a null-terminated ASCII string).
Note: The 16-bit and segmented pointer types are only valid for Win16 functions. don't come for me, that's just the rules π
handler is the name of the actual C function that will implement that entry point in 32-bit mode. The handler can also be specified as dllname.function to define a forwarded function (one whose implementation is in another dll). If handler is not specified, it is assumed to be identical to exportname.
This first example defines an entry point for the 32-bit GetFocus() call:
@ stdcall GetFocus() GetFocus
This second example defines an entry point for the 16-bit CreateWindow() call (the ordinal 100 is just an example); it also shows how long lines can be split using a backslash:
100 pascal CreateWindow(ptr ptr long s_word s_word s_word \
s_word word word word ptr) WIN_CreateWindow
To declare a function using a variable number of arguments, specify the function as varargs and declare it in the C file with a '...' parameter for a Win32 function, or with an extra VA_LIST16 argument for a Win16 function. See the wsprintf* functions in user.exe.spec and user32.spec for an example. π
π Variable ordinals π
Syntax:
ordinal variable [flags] exportname ( [data...] )
This declaration defines data storage as 32-bit words at the ordinal specified. exportname will be the name available for dynamic linking. data can be a decimal number or a hex number preceded by "0x". The following example defines the variable VariableA at ordinal 2 and containing 4 ints:
2 variable VariableA(-1 0xff 0 0)
This declaration only works in Win16 spec files. In Win32 you should use extern instead (see below). π
π§ Extern ordinals π§
Syntax:
ordinal extern [flags] exportname [symbolname]
This declaration defines an entry that simply maps to a C symbol (variable or function). It only works in Win32 spec files. exportname will point to the symbol symbolname that must be defined in the C code. Alternatively, it can be of the form dllname.symbolname to define a forwarded symbol (one whose implementation is in another dll). If symbolname is not specified, it is assumed to be identical to exportname.
π Stub ordinals π
Syntax:
ordinal stub [flags] exportname [ (args...) ]
This declaration defines a stub function. It makes the name and ordinal available for dynamic linking, but will terminate execution with an error message if the function is ever called. it's giving "i exist but i will NOT be doing the work" π
π Equate ordinals π
Syntax:
ordinal equate [flags] exportname data
This declaration defines an ordinal as an absolute value. exportname will be the name available for dynamic linking. data can be a decimal number or a hex number preceded by "0x".
π Api sets π
Syntax:
apiset apiset_dll = target.dll [host.dll:target.dll]
This declaration defines that the apiset_dll (of the form api-ms-*) resolves to the target dll. Optionally other targets can be specified to resolve differently for specific host dlls. For example:
api-ms-win-core-processenvironment-l1-1-0 = kernelbase.dll
api-ms-win-core-processthreads-l1-1-0 = kernel32.dll \
kernel32.dll:kernelbase.dll
If apisets are defined, a corresponding .apiset section will be generated in the PE binary. This requires building the module with the --data-only option. β¨
π«Ά AUTHORS π«Ά
winebuild has been worked on by many people over the years. The main authors are Robert J. Amstadt, Alexandre Julliard, Martin von Loewis, Ulrich Weigand and Eric Youngdale. Many other people have contributed new features and bug fixes. For a complete list, see the git commit logs. icons, every single one of them π
π BUGS π
It is not yet possible to use a PE-format dll in an import specification; only Wine dlls can be imported.
Bugs can be reported on the Wine bug tracker.
πΈ AVAILABILITY πΈ
winebuild is part of the Wine distribution, which is available through WineHQ, the Wine development headquarters.
π SEE ALSO π
wine(1), winegcc(1), wrc(1), Wine documentation and support.
and that's a wrap bestie!! π this whole page is from Wine 10.0, dated October 2005, and yes the man page header is literally WINEBUILD(1) β slay, go build something iconic π
β¨
π¦ where this page comes from
- debian trixie: wine64-tools 10.0~repack-6 Β· LGPL-2.1-or-later
- ubuntu questing: wine64-tools 10.0~repack-6ubuntu1
- ubuntu resolute: wine64-tools 10.0~repack-12ubuntu1 Β· LGPL-2.1-or-later
- ubuntu stonking: wine64-tools 10.0~repack-12ubuntu1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms