Wiki copymirror

This is a mirror of the wiki at pascal.chat. Editing, history and sign-in are there.

Using Lazarus for other computer languages

English · Magyar · Русский

Lazarus is great for Free Pascal. But you can use the IDE for other languages too. This is useful to port C code or to edit cross multi tier applications, without the need to use different editors and reducing the trouble when switching between different sets of shortcuts and menu entries.

Syntax Highlighting

Lazarus comes with syntax highlighting for more than a dozen languages. The language is guessed from the file extension. The colors can be setup in the editor options.

If your language is not yet there, you can either use one of the existing highlighters by extending the list of file extensions in the editor options. Or you can create your own highlighter and send us the new highlighter. The easiest way to create a new highlighter is to copy an existing file in lazarus/components/synedit/. The highlighter units all begin with 'synhighlighter', for example synhighlighterphp.pp is the php highlighter.

Hint: You can quick switch the syntax highlighter for a file via the popup menu of the source editor. Just right click / file settings / highlighter.

Compilation

To setup the compile command there are three possibilities:

1. Create a new shortcut

You can create a new shortcut and a menu item, that starts an external program with Tools / Configure Custom Tools / Add.

For example to invoke 'make' to compile via Makefile:

The MakeExe macro function appends the file extension '.exe' under windows. The ProjPath macro is replaced by the current project directory - the directory where the .lpi file is.

Pros

Cons

2. Replace the compile command of the project

When you press F9 or Ctrl-F9 the IDE checks if something has changed and invokes the compiler. The compiler is normally FPC, but you can replace that with a command of your choice.

Open Project / Compiler Options / Compilation. Then disable in the Compiler box all options Compile, Build and Run. Then write the new command in the Execute before box and enable Show all messages.

For example to invoke 'make' to compile via Makefile:

$MakeExe(make)

The MakeExe macro function appends the file extension '.exe' under windows. The working directory is always the project directory - where the .lpi file is.

Pros

Cons

3. Define a compile command for a single file

Normally when pressing F9 or Ctrl-F9 the IDE compiles a project. But you can override this behavior for each file in a project via Run / Configure Build+Run file.

This works pretty much like the two above examples.

Pros

Cons

See Also


From the Free Pascal wiki, page "Using Lazarus for other computer languages", as it stood on 2015-08-21 after a change by Alextp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .