Difference between revisions of "Blitz:Compiling"

From Amiga Coding
Jump to: navigation, search
(Created page with "Compiling your program is very easy in Blitz Basic / AmiBlitz. The integration of the editor and compiler streamlines the process so you don't have to worry about linking libr...")
 
(Compiler Settings)
Line 30: Line 30:
 
==Compiler Settings==
 
==Compiler Settings==
 
Open the Compiler Settings window using the appropriate option in the Compiler menu. This gives many options for controlling how your program is built.
 
Open the Compiler Settings window using the appropriate option in the Compiler menu. This gives many options for controlling how your program is built.
 +
 
[[File:BlitzCompilerSettingsWindow.png]]
 
[[File:BlitzCompilerSettingsWindow.png]]
 +
 +
  
 
[[Category:Blitz Basic / AmiBlitz|Blitz]]
 
[[Category:Blitz Basic / AmiBlitz|Blitz]]

Revision as of 18:02, 27 August 2015

Compiling your program is very easy in Blitz Basic / AmiBlitz. The integration of the editor and compiler streamlines the process so you don't have to worry about linking libraries or creating make files. All compiling activities are accessed from the Compiler menu in the editor, and the default settings are suitable for starting off so you don't need to worry about them for making your first "Hello World"!

Testing Your Program

The first compiling function you'll probably use is the Compile and Run option. This option compiles your program and runs it from within the Blitz environment. Your program is compiled and assembled in memory, and then executed just like any other program except it doesn't exist as a program on disk.

By default, the Blitz debugger is enabled, and will also be run with your program. This allows you catch many problems and monitor your program's execution, but does slow it down quite a bit as a result. With the debugger disabled (see Compiler Options below), your program will run at the same speed as it would if it was a stand-alone executable.

A Shell window is opened for your program to use for its default input and output, so you can use it as if it was started from the AmigaDOS Shell.

If your program has already been compiled and run, there is also a Run menu item which simply re-executes the last compiled version of your program. This saves the compile time but doesn't take into account any changes to the source since the last time it was compiled.

Note: This function does not behave correctly under OS4 and often crashes, presumably due to whatever tricks it uses not being compatible with the 68k emulation. I haven't tested it under MorphOS yet...

AmiBlitz also provides a Save, Compile and Run option which is useful for saving your source file before compiling and running it, just in case your program crashes and causes you to lose any unsaved source code changes.

Startup Parameters

When testing a program, occasionally you might need to check how it behaves given certain file arguments through the Shell. These parameters can be set for testing using the Set CLI Parameters menu item. Simply enter the required arguments here and test your program. These arguments are saved when you save your project.

Working Directory

By default, when testing, your program is run as if it's in the Blitz directory. This might not work well if your program expects to have certain other files with it, e.g. graphics files to load for a game. To set the directory to test your program from to a different location, you need to create an executable first using the Create Executable... menu option. Once that is done, your test program will use the directory you chose in which to create the executable as its own directory too. This will remain the case until you create a new executable in a different location. Don't worry if the program isn't ready to be made into an executable just yet, it'll still work :)

Creating Executables

Once your program is ready to be made into a stand-alone executable, choose the Create Executable... menu item (Create File in the original Blitz Basic 2.1 TED). This will ask you to select a location and filename for your executable program. Blitz will then compile it and build your executable automatically, ready to try out in the "real world"!

Note: You should always disable the debugger before creating your executable. The debugger includes special extra instructions in the file to communicate with the debugger, and these cause the executable to be much larger than it would be otherwise. It will also crash under OS4!

Creating Minimised Executables

AmiBlitz includes an extra option for optimizing executables. This scans the code more thoroughly to remove any unneeded instructions, and so creates a smaller executable file. The downside of this is that is usually takes much longer as the compiler often has to make multiple passes instead of just one or two. Selecting the Create Minimised Executable menu item will create a new, smaller executable in the location selected by the Create Executable... function. This probably only needs to be used for the final release version of your program once all testing is complete.

Compiler Settings

Open the Compiler Settings window using the appropriate option in the Compiler menu. This gives many options for controlling how your program is built.

BlitzCompilerSettingsWindow.png