Using the command line compiler
Introduction
The command line compiler is located in the subdirectory 'Compilers\' from the PureBasic folder. The easier way to access this is to add this directory in the windows PATH variable, which will give access to all the commands of this directory at all times.
Command switchs
/? : display a quick help about the compiler.
/COMMENTED : create a commented '.asm' output file when creating an executable. This file can be re-assembled later when the needed modifications have been made. This option is for advanced programmers only.
/DEBUGGER : enable the debugger support.
/EXE "Filename" : create a standalone Executable or DLL specified by the filename at the desired path location.
/ICON "IconName" : add the specified icon to the executable.
/INLINEASM : enable the inline asm feature (asm routines can be written directly in the BASIC source code).
/RESIDENT "Filename" : create a resident file specified by the filename.
/CONSOLE: output file in Console format. Default format is Win32.
/DLL: output file is a DLL.
/XP: Add the Windows XP theme support to the executable.
/REASM: Reassemble the PureBasic.asm file into an executable. This allow to use the /COMMENTED function, modify the asm output and creates the executable again.
/LINENUMBERING: Add lines and files information to the executable, which can slow it considerably. This allows the OnError library to report the file and linenumber of an error.
/QUIET: Disable all unnecessary text output, very useful when using another editor.
/STANDBY: Loads the compiler in memory and wait for external commands (editor, scripts...).
/MMX, /3DNOW, /SSE or /SSE2: Creates a processor specific executable. This means than if a processor specific routine is available it will be used for this executable. Therefore, the executable will run correctly only on computer with this kind of CPU.
/DYNAMICCPU: Creates a executable containing all the available processor specific routines. When the program is started, it looks for the processor type and then select the more appropriates routines to use. This makes a bigger executable, but result in the fastest possible program.
/RESOURCE "Filename": Add a Windows resource file (.rc) to the created executable or DLL. This should be not a compiled resource file, but an ascii file with the directives in it. It's possible to specify only one resource, but this file can include other resource script if needed.
/LINKER "ResponseFile": Specify a file which contains commands to be passed directly to the linker. On Windows, PureBasic use the PellesC linker (polink), more informations about the possible options can be found in the related documentation.
/IGNORERESIDENT "Filename": Doesn't load the specified resident file when the compiler starts. It's mostly useful when updating a resident which already exists, so it won't load it.
/CONSTANT Name=Value: Creates the specified constant with the given expression. Example: 'pbcompiler test.pb /CONSTANT MyConstant=10'. The constant #MyConstant will be created on the fly with a value of 10 before the program gets compiled.
/UNICODE: Use unicode instead ascii for strings management.
/THREAD: Use thread safe runtime for strings and general routines.
/SUBSYSTEM "Name": Uses the specific subsystem to replace a set of internal functions.
The following two compiler options are needed for creating programs running on Microsoft Vista OS. They are both options for the included manifest, so they are ignored on older windows versions. With none of these switches, the exe will run as a normal user as well, but with virtualisation turned on (i.e. registry and file redirection). It is recommended to use the /USER switch to turn of virtualisation for all programs that comply to the standard user priviledges, as it is only intended for compatibility for older programs. These options are also available in the IDE compiler options.
/ADMINISTRATOR: Will cause the program to request admin priviledges at start. The program will not run without it. This option is needed. Note: You can also debug programs with this flag, but only with the standalone gui debugger (as it must run in elevated mode as well).
/USER: The program will run as the user who started it. Virtualisation for the exe is turned off.Example:
CLI> pbcompiler sourcecode.pbThe compiler will compile the source code and execute it.
CLI> pbcompiler sourcecode.pb /DEBUGGER /INLINEASMThe compiler will compile the source code and execute it with debugger and inline asm support.CLI> pbcompiler "C:\Project\Source\DLLSource.pb" /EXE "C:\Project\project.dll" /DLLThe compiler will compile the source code (here with full path) and create the dll "project.dll" in the given directory.