======================
Installation
======================

This chapter describes the process of installing a binary version of AGX Dynamics.



The name of the installation executable informs you of the build environment used when building the libraries:



agx-setup-<*version*>-<*platform*>-<*compiler*>-<*precision*>.exe



For example:


**agx-setup-2.12.0.0-x64-VS2013-double.exe**


| AGX version 2.30.0.0
| Platform: 64bit
| Compiler: Visual Studio 2019

----------------------
Install AGX in Windows
----------------------

Start the installation executable.


.. _fig-install_agx_in_windows_1:

.. figure:: images/install_agx_in_windows_1.png

  After the splash screen you will get a verification question (if you have UAC enabled) which will show you a verified installer from Algoryx Simulation.


If you have a prior installation of AGX you will get a query regarding uninstalling that version. It is recommended that you do so.



.. _fig-install_agx_in_windows_2:

.. figure:: images/install_agx_in_windows_2.png



.. _fig-install_agx_in_windows_3:

.. figure:: images/install_agx_in_windows_3.png

  Next is the uninstall window, just press Yes to remove the previous installation.

  If you have created additional files, such as CMake, visual studio project files etc, they will not be removed. You will have to manually remove these files.


.. _fig-install_agx_in_windows_4:

.. figure:: images/install_agx_in_windows_4.png

  Uninstall window.


.. _fig-install_agx_in_windows_5:

.. figure:: images/install_agx_in_windows_5.png

  Message indicating uninstall is performed.
  When the uninstall is finished. The installer will continue with the install of AGX.


.. _fig-install_agx_in_windows_7:

.. figure:: images/install_agx_in_windows_7.png

  License agreement.


.. _fig-install_agx_in_windows_8:

.. figure:: images/install_agx_in_windows_8.png

  Install destination


.. _fig-install_agx_in_windows_9:

.. figure:: images/install_agx_in_windows_9.png

  Name of entry in Start menu


.. _fig-install_agx_in_windows_11:

.. figure:: images/install_agx_in_windows_11.png

  Install in progress.


.. _fig-install_agx_in_windows_12:

.. figure:: images/install_agx_in_windows_12.png

  The final stage. If python libraries are installed, a command window will appear during the installation process:

.. _fig-install_agx_in_windows_10:

.. figure:: images/install_agx_in_windows_10.png
 
After the installation done and the default checkboxes was left untouched, the AGX Dynamics startup page will appear with with documentation, tutorials and examples.


.. _fig-install_agx_in_windows_13:

.. figure:: images/install_agx_in_windows_13.png



-----------------------
Install on Ubuntu 20.04
-----------------------

Different Linux distributions and versions might have different installation procedures.
The procedure described here matches the one used for installing a deb-file on Ubuntu 20.04.


By default, AGX Dynamics is installed into /opt/Algoryx/AGX-<version>


.. code-block:: console

  $ sudo apt-get update  # Refresh package lists if needed
    ...
  $ sudo apt install ./agx-2.31.1.0-amd64-ubuntu_20.04.deb
	Reading package lists... Done
	Building dependency tree
	Reading state information... Done
	Note, selecting 'agx' instead of 'agx-2.31.1.0-amd64-ubuntu_20.04.deb'
	The following additional packages will be installed:
    ...
	Suggested packages:
    ...
	The following NEW packages will be installed:
    ...
	0 upgraded, 56 newly installed, 0 to remove and 0 not upgraded.
	Need to get 36.8 MB/517 MB of archives.
	After this operation, 2847 MB of additional disk space will be used.
	Do you want to continue? [Y/n]

  $ ls /opt/Algoryx/AGX-2.31.1.0/
	AGX_build_settings.txt  LICENSE.TXT  applications     conanfile.txt  include         swig
	CMakeLists.txt          README.TXT   bin              data           lib             tutorials
	CMakeModules            agxOSG       build-info.json  doc            setup_env.bash
  
You need to manually place your AGX license in the installation directory. 
Also, before running any AGX simulation the shell environment must be updated with some environment variables.
Do this by starting a bash shell and execute the following command:

.. code-block:: console

  > source /opt/Algoryx/AGX-<version>/setup_env.bash


AGX binaries and libraries use embedded rpath information to help locate needed shared
libraries. The environment script previously set LD_LIBRARY_PATH but has been updated
to no longer do so. If your usecase has trouble finding the needed libraries, 
the following can be used after sourcing the environment script:

.. code-block:: console

  > export LD_LIBRARY_PATH:$LD_LIBRARY_PATH:/opt/Algoryx/AGX-<version>/lib


You can then start the tutorial applications or load Python scripts using agxViewer:

.. code-block:: console

  $ agxViewer data/python/cables.agxPy


The Linux package also install desktop files which most window managers will find
automatically. Via these desktop files, the window manager will show menu options 
in the development section which help locate AGX API documentation, the user manual 
and the tutorials/demos.

-----------------
Install on MacOS
-----------------

To install AGX on MacOS, double click the downloaded installer file and follow the instructions. The installed AGX environment will be available in `/opt/Algoryx/AGX-<version>`.

NOTE: AgxTerrain is currently not supported on MacOS

To use AGX with python, you must have Python3.8 installed on your machine, using the `homebrew package manager <https://brew.sh/>` _

.. code-block:: console

  > brew install python@3.8

You need to manually place your AGX license in the installation directory. Also, before running any AGX simulation the shell environment must be updated with some environment variables.

Do this by starting a bash shell and execute the following command:

.. code-block:: console

  > source /opt/Algoryx/AGX-<version>/setup_env.bash


You can then start the tutorial applications or load Python scripts using agxViewer:

.. code-block:: console

 > agxViewer data/python/cables.agxPy


------------------
Installing license
------------------

The license file agx.lic should be placed into the installation directory. Note, under windows that might require administrative rights depending on where AGX Dynamics where installed.

The license file can also be placed wherever you like, just as long as the file can be located with the agxIO::Environment utility. For more see information about how to specify paths to resource files in :numref:`locating-files`.
