WINEBUILD(1)
π WINEBUILD(1) π
okay bestie, welcome to the Wine Developers Manual, and today we're getting into winebuild β yes, that's the same winebuild(1) you keep seeing in your man searches, she's a whole icon, let's go π
β¨ NAME β¨
winebuild β the Wine dll builder. That's it, that's the job π
πΈ SYNOPSIS πΈ
winebuild [options] [inputfile...]
π¦ DESCRIPTION π¦
So basically, winebuild generates the assembly files you need to build a Wine dll β and a Wine dll is lowkey just a Win32 dll wrapped up inside a Unix library, no cap. Two vibes in one girlie π«Ά
winebuild has different modes, depending on what kind of file you ask it to generate. You pick the mode with one of the mode options listed down below. And on top of the mode option, you can also throw in a bunch of other command-line options, all described in the OPTIONS section, because she's flexible like that πβοΈ
π MODE OPTIONS π
okay so this is the part where you have to commit. You have to specify exactly one of the following options, depending on what you want winebuild to generate. Not zero. Not two. One. Main character energy, singular β¨
--dllβ Build an assembly file from a.specfile (peep SPEC FILE SYNTAX for the details), or from a standard Windows.deffile. You pass the.spec/.deffile 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 will be linked into the final dll β that waywinebuildcan get the list of all the undefined symbols that need to be imported from other dlls π₯--exeβ Build an assembly file for an executable. This is basically the same as the--dllmode except it doesn't require a.spec/.deffile as input, because an executable doesn't need to export functions. Some executables do export functions though, and for those you can specify a.spec/.deffile via the-Eoption. The executable gets named from the.spec/.deffile name if it's there, 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β Build a.deffile from a spec file. The.specfile is specified via the-Eoption. You use this when building dlls with a PE (Win32) compiler π--implibβ Build a.aimport library from a spec file. The.specfile is specified via the-Eoption. And if the output library name ends in.delay.a, then you get a delayed import library instead. Cute surprise β¨--staticlibβ Build a.astatic library from object files. Simple, clean, slay π--resourcesβ Generate a.ofile containing all the input resources. This one's useful when building with a PE compiler, since the PE binutils literally cannot handle multiple resource files as input (rude of them tbh). For a standard Unix build, the resource files are automatically included when building the spec file, so there's no need for an intermediate.ofile at all π--builtinβ Mark a PE module as a Wine builtin module, by adding the"Wine builtin DLL"signature string 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 are executed. Order matters, bestie β
π OPTIONS π
the full menu, no skips, we eat every bite:
--as-cmd=as-commandβ Specify the command to use to compile assembly files. The default isas.-b, --target=cpu-manufacturer[-kernel]-osβ Specify the target CPU and platform on which the generated code will be built. The target specification is in the standard autoconf format, as returned byconfig.sub. Yes,-kernelis part of the format β it goes in the middle, don't lose her π«Ά-B directoryβ Add the directory to the search path for the various binutils tools likeas,nmandld.--cc-cmd=cc-commandβ Specify the C compiler to use to compile assembly files. The default is to instead use the assembler specified with--as-cmd.-d, --delay-lib=nameβ Set the delayed import mode for the specified library, which must 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. She's patient like that π-D symbolβ Ignored, for compatibility with the C compiler. Not everything's about you,-Dπ-e, --entry=functionβ Specify the module entry point function. If you don't specify it, the default isDllMainfor dlls, andmainfor executables (and if the standard Cmainis not defined,WinMainis used instead). This is only valid for Win32 modules.-E, --export=filenameβ Specify a.specfile (see SPEC FILE SYNTAX for the details), or a standard Windows.deffile that defines the exports of the DLL or executable that is 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. (heads up though: for symbols defined in another dll, a forward specification must be used instead.)-f optionβ Specify a code generation option. Currently-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. Fake it till you make it, but make it literal β¨-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. Your emergency exit πͺ-H, --heap=sizeβ Specify the size of the module local heap in bytes (only valid for Win16 modules). The default is no local heap.-I directoryβ Ignored, for compatibility with the C compiler. Again. Not your era,-Iπ-k, --kill-atβ Remove the stdcall decorations from the symbol names in the generated.deffile. Only meaningful in--defmode.-K flagsβ Ignored, for compatibility with the C compiler. The third ignored one, they're just here for the vibes π--large-address-awareβ Set a flag in the executable to notify the loader that this application supports address spaces larger than 2 gigabytes. Big girl energy, literally π--ld-cmd=ld-commandβ Specify the command to use to link the object files. The default isld.-L, --library-path=directoryβ Append the specified directory to the list of directories that are searched for import libraries.-l, --library=nameβ Import the specified library, looking for a correspondinglibname.deffile in the directories specified with the-Loption.-m16,-m32,-m64β Generate respectively 16-bit, 32-bit or 64-bit code. Pick your era π-marm,-mthumbβ Select between generating code that executes in ARM and Thumb states.-march=option,-mcpu=option,-mfpu=option,-mfloat-abi=optionβ Set code generation options for the assembler.-mno-cygwinβ Build a library that uses the Windows runtime instead of the Unix C library.-munixβ Build the Unix counterpart of a builtin module.-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. Sibling solidarity π-N, --dll-name=dllnameβ Set the internal name of the module. It is 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 to use 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). If the output file name ends in.o, the text output is sent to a temporary file that is then assembled to produce the specified.ofile.-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. Hoarder mode, but make it debugging π--subsystem=subsystem[:major[.minor]]β Set the subsystem of the executable, which can be one of the following:consoleβ for a command line executablewindowsβ for a graphical executablenativeβ for a native-mode dllwinceβ for 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.
-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. Peer pressure, but for linkers π«Ά-v, --verboseβ Display the various subcommands being invoked bywinebuild. She's telling you everything, and honestly? We're listening.--versionβ Display the program version and exit.-w, --warningsβ Turn on warnings. π
friendly reminder bestie: you still need exactly one mode option from up top before any of this does anything. Don't forget her π
β¨ SPEC FILE SYNTAX β¨
okay bestie, so a spec file is literally just a list of ordinal declarations, and the general syntax is giving this:
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 have to fit on one single line, unless you escape the end of the line with a backslash character. And the # character anywhere in a line? It makes the rest of that line ignored as a comment. periodt. π
ordinal is the ordinal number for the entry point, or '@' for automatic ordinal allocation (Win32 only).
flags is a little series of optional flags, each one preceded by a - character. The supported flags are:
-norelayβ this entry point is not displayed in relay debugging traces (Win32 only).-nonameβ the entry point gets exported by ordinal instead of by name. The name is still available for importing, so don't panic.-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 the thiscall calling convention (first parameter in%ecxregister on i386).-fastcallβ the function uses the fastcall calling 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 is literally defining a function entry point. The prototype defined by exportname ( [args...] ) specifies the name available for dynamic linking and the format of the arguments. You can use '@' 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. π«Ά
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. so like, don't call it unless you want chaos. π
β¨ 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".
π 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.
π 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 the whole spec-file sermon, bestie π This iconic page is from Wine 6.0, dated October 2005, and it's literally WINEBUILD(1) energy forever. No cap. π β¨
π¦ where this page comes from
- ubuntu jammy: wine64-development-tools 6.0+repack-1ubuntu1 Β· 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