Difference between revisions of "Multiple Lazarus"

From Free Pascal wiki
Jump to navigationJump to search
(wikitable and syntaxhighlight)
(More explanation, terminology, layout, capitalization, spelling/grammar)
Line 1: Line 1:
 
{{Multiple Lazarus}}
 
{{Multiple Lazarus}}
 +
== Multiple Lazarus instances ==
 +
You can have one directory with Lazarus in it on your system or more. These directories can contain the same or different versions of Lazarus and can be made to work independent of each other (see the section dealing with --primary-config-dir below).
 +
Because you don't have to install Lazarus and the versions may be the same, the concept of having more than one Lazarus directory on your system will be called "multiple instances" in this article.
  
== Who needs multiple lazarus and who does not? ==
+
== Who needs multiple Lazarus instances and who does not? ==
 +
You need multiple Lazarus instances...
 +
*to have several versions of Lazarus
 +
*to have one Lazarus version compiled with several different versions of FPC
  
You need multiple lazarus versions ...
+
You don't need multiple instances...
*to have several versions of lazarus
 
*to have one lazarus compiled with several different versions of FPC
 
 
 
You don't need multiple versions ...
 
 
*to test your project with different widgetsets
 
*to test your project with different widgetsets
 
*to cross compile
 
*to cross compile
Line 13: Line 15:
 
== The Lazarus directory ==  
 
== The Lazarus directory ==  
  
The lazarus directory is overridable using --lazarusdir, this is useful when running lazarus from e.g. USB sticks with varying mountpoints or driveletters.
+
The Lazarus directory (i.e. the directory where the Lazarus application is) is overridable using --lazarusdir, this is useful when running Lazarus from e.g. USB sticks with varying mountpoints or driveletters.
  
 
== The config directory ==
 
== The config directory ==
  
All IDE options are saved to its config directory. Under Linux, Mac OS X and BSD the default config directory is ~/.lazarus. Note the beginning dot, which makes it a hidden directory.
+
All IDE options for an instance are saved to a config directory. Under Linux, Mac OS X and BSD the default config directory is ~/.lazarus. Note the beginning dot, which makes it a hidden directory.
  
This doesn't apply to Windows, because settings are saved to the User AppData folder, which maps to a different directory depending on the Windows version and language. See also information here: [[Multiple Lazarus#Windows]]. Note that you won't see the configuration directory in Windows unless you select to see hidden and system files.
+
On Windows, settings are saved to the User AppData folder, which maps to a different directory depending on the Windows version (and language, in Windows XP and earlier).  
 +
See also information here: [[Multiple Lazarus#Windows]]. Note that you won't see the configuration directory in Windows unless you select to see hidden and system files.
 +
To view the directory, type:
 +
<syntaxhighlight lang="dos">
 +
%localappdata%
 +
<syntaxhighlight>
 +
in the Start/Run box or in the address bar of Windows Explorer, which should bring you to the Local Application Data directory. For default installs, the settings are stored in the Lazarud directory showed there.
  
 
{| class="wikitable"
 
{| class="wikitable"
! Operating System !! Default location for the config directory
+
! Operating System !! Default location for the config directory !! Remarks
 
|-
 
|-
|Linux, Mac OS X, BSD, other UNIXes||~/.lazarus
+
|Linux, Mac OS X, BSD, other UNIXes||~/.lazarus||Hidden directory
 
|-
 
|-
|Windows XP||C:\Documents and Settings\<User name>\Local Settings\Application Data\lazarus
+
|Windows XP||C:\Documents and Settings\<User name>\Local Settings\Application Data\lazarus||English Windows; others may have different paths
 
|-
 
|-
 
|Windows Vista||C:\Users\<User name>\AppData\Local\lazarus\
 
|Windows Vista||C:\Users\<User name>\AppData\Local\lazarus\
Line 33: Line 41:
 
The config directory can '''not''' be shared between different Lazarus versions. A newer Lazarus can read older configs and will update them automatically. There is no guarantee that an older version can read config files of a newer version. It is always a good idea to make a backup of your configs from time to time for the case you changed something weird and don't know what it was.
 
The config directory can '''not''' be shared between different Lazarus versions. A newer Lazarus can read older configs and will update them automatically. There is no guarantee that an older version can read config files of a newer version. It is always a good idea to make a backup of your configs from time to time for the case you changed something weird and don't know what it was.
  
The config directory can be given at command line with the --primary-config-path parameter. For example  
+
=== Solution for separating instances using multiple config dirs ===
 +
The config directory can be given at the command line with the --primary-config-path parameter (shorter version: --pcp). For example  
 
<syntaxhighlight lang="bash">lazarus --primary-config-path=~/.lazarus2</syntaxhighlight>
 
<syntaxhighlight lang="bash">lazarus --primary-config-path=~/.lazarus2</syntaxhighlight>
will start an IDE using ''~/.lazarus2'' as config directory. This way you can have an arbitrary number of config directories and start several independent Lazarus instances. If you use this often, then a small bash script can be created:
+
will start an IDE using ''~/.lazarus2'' as config directory. This way you can have an arbitrary number of config directories and start several independent Lazarus instances.
 +
As Lazarus creates the settings files from default if they don't exist, you can specify empty directories if you want.
 +
 
 +
If you use this often, then a small bash script can be created:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
#!/bin/sh
 
#!/bin/sh
Line 41: Line 53:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== The lazarus files ==
+
== The Lazarus files ==
 +
 
 +
The Lazarus source archive is contained in one directory. You can simply compile Lazarus (see installation instructions) and a lot of files and subdirectories will be created, but still in that single directory.
  
The normal Lazarus (sources and resources) is only one directory. Just copy this directory and get a whole new lazarus. The normal lazarus can be downloaded as zip or from svn. When you compile this lazarus all files will be created in sub directories of this directory.
+
A Lazarus instance (sources and resources) is only one directory. Just copy this directory and you get a whole new Lazarus instance.  
  
You don't need to '''install'' lazarus. But if you install lazarus you get some nice shortcuts on your desktop and some files are associated. These things are platform dependent and there is always only one lazarus ''installed''. The official installers do not support to ''install'' lazarus multiple times. But you can add another lazarus manually quite easily.
+
You don't need to '''install'' Lazarus. But if you do install Lazarus you get some nice shortcuts on your desktop and some file types (e.g. lpk, lpi, pas) are associated with that Lazarus installation. These things are platform dependent and there is always only one Lazarus ''installed''. The official installers do not support ''installing'' Lazarus multiple times. But you can add another Lazarus instance manually quite easily (of course, file associations etc are still only linked to one Lazarus instance).
  
 
=== Linux ===
 
=== Linux ===
  
==== Example 1 : A normal installed lazarus plus the svn version ====
+
==== Example 1 : A normally installed Lazarus instance plus the svn version ====
  
Download and install the lazarus packages as normal.
+
Download and install the Lazarus packages as normal.
  
Then download the lazarus svn to a directory of your choice, preferably somewhere in your home directory. See here [[Installing_Lazarus#Downloading_Lazarus_SVN]].
+
Then download the Lazarus svn archive to a directory of your choice, preferably somewhere in your home directory. See here [[Installing_Lazarus#Downloading_Lazarus_SVN]].
  
==== Example 2 : A normal installed lazarus plus a copy in the home directory ====
+
==== Example 2 : A normally installed Lazarus instance plus a copy in the home directory ====
  
Download and install the lazarus packages as normal.
+
Download and install the Lazarus packages as normal.
  
Then copy lazarus to your home directory and change the ownership of the files:
+
Then copy the Lazarus directory to your home directory and change the ownership of the files:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
cp -a /usr/lib/lazarus $(HOME)/
 
cp -a /usr/lib/lazarus $(HOME)/
Line 67: Line 81:
 
(Note: The chown line assumes that your group has the same name as your username. If not, replace $USER:$USER with your username:groupname)
 
(Note: The chown line assumes that your group has the same name as your username. If not, replace $USER:$USER with your username:groupname)
  
Then change your lazarus desktop/menu shortcut to start
+
Then change your Lazarus desktop/menu shortcut to start
 
<syntaxhighlight lang="bash">/home/username/lazarus/startlazarus --pcp=~/.lazaruslocal</syntaxhighlight>
 
<syntaxhighlight lang="bash">/home/username/lazarus/startlazarus --pcp=~/.lazaruslocal</syntaxhighlight>
  
Line 73: Line 87:
 
/home/username/lazarus
 
/home/username/lazarus
  
Now you have a local copy, that you can edit and recompile. Don't forget to close source files of /usr/lib/lazarus.
+
Now you have a local copy that you can edit and recompile. Don't forget to close source files of /usr/lib/lazarus.
  
 
=== Windows ===
 
=== Windows ===
Line 79: Line 93:
 
==== Example 1: SVN and Release ====
 
==== Example 1: SVN and Release ====
  
This is to have both SVN and last Release version of Lazarus.
+
This is to have both SVN and last release version of Lazarus.
  
1) Install Lazarus last Release and check setup option 'create desktop shortcut', you will get 'Lazarus.lnk' in desktop.
+
1) Install Lazarus last release and check setup option 'create desktop shortcut', you will get 'Lazarus.lnk' on the desktop.
  
2) Get Lazarus from SVN and compile, then create a shortcut in desktop for 'lazarus.exe' and rename it to 'Lazarus SVN.lnk'.
+
2) Get Lazarus from SVN and compile, then create a shortcut on your desktop for 'lazarus.exe' and rename it to 'Lazarus SVN.lnk'.
  
Then you can set the config dir for each version editing the shortcut path to executable:
+
Then you can set the config dir for each version editing the shortcut path to the executable:
  
This is for Release, if you don't change nothing the config will be saved in the user app data folder (in Win7 C:\Users\$username$\AppData\Local\Lazarus):
+
This is for release, because you don't change the primary config path parameter, the config will be saved in the default path:
 
<syntaxhighlight lang="dos">C:\lazarus\startlazarus.exe</syntaxhighlight>
 
<syntaxhighlight lang="dos">C:\lazarus\startlazarus.exe</syntaxhighlight>
  
For SVN store the settings in the folder 'C:\lazsvncfg\':
+
For SVN, store the settings e.g. in the folder 'C:\lazsvncfg\':
 
<syntaxhighlight lang="dos">C:\FPC\laz\startlazarus.exe --primary-config-path=C:\lazsvncfg</syntaxhighlight>
 
<syntaxhighlight lang="dos">C:\FPC\laz\startlazarus.exe --primary-config-path=C:\lazsvncfg</syntaxhighlight>
  
 
[[Category:Lazarus]]
 
[[Category:Lazarus]]

Revision as of 10:08, 18 September 2012

Deutsch (de) English (en) español (es) français (fr) polski (pl) português (pt) русский (ru)

Multiple Lazarus instances

You can have one directory with Lazarus in it on your system or more. These directories can contain the same or different versions of Lazarus and can be made to work independent of each other (see the section dealing with --primary-config-dir below). Because you don't have to install Lazarus and the versions may be the same, the concept of having more than one Lazarus directory on your system will be called "multiple instances" in this article.

Who needs multiple Lazarus instances and who does not?

You need multiple Lazarus instances...

  • to have several versions of Lazarus
  • to have one Lazarus version compiled with several different versions of FPC

You don't need multiple instances...

  • to test your project with different widgetsets
  • to cross compile

The Lazarus directory

The Lazarus directory (i.e. the directory where the Lazarus application is) is overridable using --lazarusdir, this is useful when running Lazarus from e.g. USB sticks with varying mountpoints or driveletters.

The config directory

All IDE options for an instance are saved to a config directory. Under Linux, Mac OS X and BSD the default config directory is ~/.lazarus. Note the beginning dot, which makes it a hidden directory.

On Windows, settings are saved to the User AppData folder, which maps to a different directory depending on the Windows version (and language, in Windows XP and earlier). See also information here: Multiple Lazarus#Windows. Note that you won't see the configuration directory in Windows unless you select to see hidden and system files. To view the directory, type:

%localappdata%
<syntaxhighlight>
in the Start/Run box or in the address bar of Windows Explorer, which should bring you to the Local Application Data directory. For default installs, the settings are stored in the Lazarud directory showed there.

{| class="wikitable"
! Operating System !! Default location for the config directory !! Remarks
|-
|Linux, Mac OS X, BSD, other UNIXes||~/.lazarus||Hidden directory
|-
|Windows XP||C:\Documents and Settings\<User name>\Local Settings\Application Data\lazarus||English Windows; others may have different paths
|-
|Windows Vista||C:\Users\<User name>\AppData\Local\lazarus\
|}

The config directory can '''not''' be shared between different Lazarus versions. A newer Lazarus can read older configs and will update them automatically. There is no guarantee that an older version can read config files of a newer version. It is always a good idea to make a backup of your configs from time to time for the case you changed something weird and don't know what it was.

=== Solution for separating instances using multiple config dirs ===
The config directory can be given at the command line with the --primary-config-path parameter (shorter version: --pcp). For example 
<syntaxhighlight lang="bash">lazarus --primary-config-path=~/.lazarus2

will start an IDE using ~/.lazarus2 as config directory. This way you can have an arbitrary number of config directories and start several independent Lazarus instances. As Lazarus creates the settings files from default if they don't exist, you can specify empty directories if you want.

If you use this often, then a small bash script can be created:

#!/bin/sh
/path/to/lazarus --primary-config-path=~/.lazarus2

The Lazarus files

The Lazarus source archive is contained in one directory. You can simply compile Lazarus (see installation instructions) and a lot of files and subdirectories will be created, but still in that single directory.

A Lazarus instance (sources and resources) is only one directory. Just copy this directory and you get a whole new Lazarus instance.

You don't need to 'install Lazarus. But if you do install Lazarus you get some nice shortcuts on your desktop and some file types (e.g. lpk, lpi, pas) are associated with that Lazarus installation. These things are platform dependent and there is always only one Lazarus installed. The official installers do not support installing Lazarus multiple times. But you can add another Lazarus instance manually quite easily (of course, file associations etc are still only linked to one Lazarus instance).

Linux

Example 1 : A normally installed Lazarus instance plus the svn version

Download and install the Lazarus packages as normal.

Then download the Lazarus svn archive to a directory of your choice, preferably somewhere in your home directory. See here Installing_Lazarus#Downloading_Lazarus_SVN.

Example 2 : A normally installed Lazarus instance plus a copy in the home directory

Download and install the Lazarus packages as normal.

Then copy the Lazarus directory to your home directory and change the ownership of the files:

cp -a /usr/lib/lazarus $(HOME)/
chown $USER:$USER -R $(HOME)/lazarus

(Note: The chown line assumes that your group has the same name as your username. If not, replace $USER:$USER with your username:groupname)

Then change your Lazarus desktop/menu shortcut to start

/home/username/lazarus/startlazarus --pcp=~/.lazaruslocal

Then start the IDE and change the environment options: Menu / Environment / Environment options ... / Lazarus directory to /home/username/lazarus

Now you have a local copy that you can edit and recompile. Don't forget to close source files of /usr/lib/lazarus.

Windows

Example 1: SVN and Release

This is to have both SVN and last release version of Lazarus.

1) Install Lazarus last release and check setup option 'create desktop shortcut', you will get 'Lazarus.lnk' on the desktop.

2) Get Lazarus from SVN and compile, then create a shortcut on your desktop for 'lazarus.exe' and rename it to 'Lazarus SVN.lnk'.

Then you can set the config dir for each version editing the shortcut path to the executable:

This is for release, because you don't change the primary config path parameter, the config will be saved in the default path:

C:\lazarus\startlazarus.exe

For SVN, store the settings e.g. in the folder 'C:\lazsvncfg\':

C:\FPC\laz\startlazarus.exe --primary-config-path=C:\lazsvncfg