Compiling your programs

Compiling is simple. Just select “Compile/Run” (F5 by default) and your program will be compiled and executed for a testing run.

To customise the compiling process, you can open the "Compiler options" dialog. The settings made there are associated with the current source file, and also remembered when you close the file. The place where this information is saved can be configured. By default, it is saved at the end of the source code as a comment. (invisible in the IDE)

In case of an error that prevents the compiler from completing the compilation, it aborts and displays an error message. This message is also logged in the error log, and the line that caused the error is marked.

The compiler menu

Compile/Run
This compiles the current source code with the compiler options that were set for it and executes it. The executable file is stored in a temporary location, but it will be executed with the current path set to the directory of the source code. (so loading a file from the same directory as the source code will work)

The source code need not be saved for this. (but any included files must be saved.)

The “Compile/Run” option respects the debugger setting (on or off) from the compiler options or debugger menu. (they are the same)

Run
This executes the last compiled source code once again. Whether or not the debugger is enabled depends on the setting of the last compilation.

Compile with Debugger
This is the same as “Compile/Run” except that it ignores the debugger setting and enabled the debugger for this compilation. This is useful when you usually have the debugger off, but want to have it on for just this one compilation.

Compile without Debugger
Same as “Compile with Debugger” except that it forces the debugger to be off for this compilation.

Restart Compiler (not present on all OS)
This causes the compiler to restart. (on windows it is always loaded) It also causes the compiler to reload all the libraries and resident files, and with that, the list of known PureBasic functions, Structures, Interfaces and Constants is updated too. This function is useful when you have added a new User Library to the PB directory, but do not want to restart the whole IDE. It is especially useful for library developers to test their library.

Compiler Options
This opens the compiler options dialog, that lets you set the options for the compilation of this source file.

The compiler options dialog:

Main source file
By enabling this option, you can define another file that will be the one sent to the compiler instead of this one. The use of this is that when you are editing a file that does not run by itself, but is included into another file, you can tell the compiler to use that other file to start the compilation.

Note: When using this option, you MUST save your source before compiling, as only files that are written to disk will be used in this case. Most of the compiler settings will be taken from the main source file, so when setting this, they are disabled. Only the debugger setting and the commandline setting will be used from the current source.

Use Icon (windows only)
Here you can set an icon that will be displayed when viewing the created executable in the explorer. It is also displayed in the title bar of your programs windows and the Taskbar. Note: This setting is only used when creating and executable, not with “Compile/Run”

Enable Debugger
This sets the debugger state (on/off) for this source code, or if the main file option is used, for that file too. This can also be set from the debugger menu.

Enable inline ASM support
This enables the inline asm parser. See the Inline x86 ASM section of the help file for more information on this option.

NT 4.0 compliant executable (Windows only)
Uses DirectX3 only for any library that uses DirectX it in order to be compatible to Windows NT 4.

Enable XP Skin support (Windows only)
Includes support for skinned windows on Windows XP

Enable OnError lines support (Windows only)
Includes line numbers information with the executable for the OnError-Library.

Library Subsystem (currently only on Linux/MacOSX)
Here you can select a different PB subsystem for compilation. Currently the following subsystems are supported:

Linux
gtk2 : uses Gtk2 instead of Gtk1.2 for the compilation (requires gtk2-dev of course)

MacOSX
gtk : uses Gtk1.2 for the compilation. (requires the X layer for MacOSX and the gtk1.2 libraries of course.
gtk2 : uses Gtk2 for the compilation
The default on MacOSX is to use the native Carbon libraries.

Executable format
This allows you to specify the created executable format:
Windows : a normal windows executable.
Console : an executable with a default console. This one still can create windows and such, but it always has a console open. When executed from a command prompt, this executable type uses the command terminal as its console and writes there, whereas the “Windows” executable would create a separate Console window when using OpenConsole().
Shared DLL : create a windows dll. See “Building a dll” for more info.
Note: When you do “Compile/Run” with a dll source code, it is executed as a normal executable. A dll is only created when you use “create executable”.

Cpu Optimisation (next to Executable format)
This setting allows to include Cpu optimised PB functions in your executable:
All CPU : The generic functions are included that run on all CPUs.
Dynamic CPU : The generic functions as well as any available CPU specific function are included. The function to execute is decided at runtime. This creates a bigger executable, but it will run as fast as possible on all CPUs.
All other options : Include only the functions for a specific CPU. The executable will not run on any Cpu that does not support this feature.

Note: No PB functions actually support this feature for now (it is ignored for them). However, some User Libraries include such optimisations.

Executable Commandline
The string given here will be passed as the commandline to the program when running it from the IDE. This has no effect when creating the final executable.

Source Newline format
This does not effect the compiler, but it sets in which newline-format the source code will be saved the next time. The setting of this field is determined when loading the file. (or uses the default value for new sources). Changing it means that the next time the source is saved, it will be in a different newline-format.

In order to develop one source for many platforms, the PureBasic IDE supports different newline-formats. However, other programs may not, so it is always a good idea to leave this at the OS default if not needed otherwise.

Version Information

By enabling this, a resource is included in the executable with information about your program. It can be viewed by right-clicking on the executable in the windows explorer and selecting "Properties". Also it can be read by other programs such as setup tools.

Fields marked with a * are required if you want to include the version info. (if not all required fields are set, the information may not display correctly on some versions of Windows.

The first two fields MUST be composed of 4 numbers separated by commas. All other fields may be any string. In the 3 empty boxes, you can define your own fields to include in the Version info block.

In all the string fields, you may include special tokens that are replaced when compiling:
%OS : replaced with the version of Windows used to compile the program
%SOURCE : replaced with the filename (no path) of the source file.
%EXECUTABLE : replaced with the name of the created executable (this only works when “create executable” is used, not with “Compile/Run”.

Furthermore, you can use any token listed with the FormatDate() command. These tokens will be replaced with their respective meaning in FormatDate() used with the date of the compilation (i.e. %yy gives the year of the compilation)

Meaning of the lower 3 fields:

File OS
Specifies the OS that this Program is compiled for. (using VOS_DOS or VOS_WINDOWS16 makes not much sense. They are only included to have the full list)

File Type
Type of the executable. (here VFT_UNKNOWN, VFT_APP or VFT_DLL only really make sense for PB programs)

Language
Specifies the language in which this version info is written.

Resources

Here you can include as many Resource scripts (*.rc files) as you want. They will be compiled and included with the executable. You can use any resource editor (for example the PellesC IDE) to create such scripts.

Note: Since Resources are a specific to the Windows platform only, PB does not include a Library to manage them and they are not further documented here. See documentation on the Windows API and resources for more information.