Trick requires various free third party utilities in order to function. All the following products are used by Trick and may already be installed as part of your OS distribution. **Install any missing dependencies with your operating system's [package manager](https://en.wikipedia.org/wiki/Package_manager).** For most operating systems, the default version of a dependency will be compatitable with Trick. Please check the specific OS instructions below for your operating system for more details.
Clang/LLVM can be installed and located manually should your package manager fail to acquire it. You can tell Trick where to find Clang/LLVM with the "--with-llvm" configuration option specified [below](TODO).
### 32-bit Mode
If you intend to build Trick in 32-bit mode, you will need 32-bit versions of the libraries in the above table. If a 32-bit version of udunits is not available through your package manager, you can build it from [source](ftp://ftp.unidata.ucar.edu/pub/udunits/udunits-2.2.25.tar.gz):
```bash
tar xfvz udunits-2.2.25.tar.gz
cd udunits-2.2.25
export CFLAGS="-m32"
./configure --prefix=/usr
make
make install
```
### Java
Trick needs the javac compiler included in the Java Development Kit (JDK). Trick will work with either the Oracle JDK or OpenJDK, but we prefer the Oracle JDK located [here](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html).
**Installing both the Oracle JDK and OpenJDK may lead to problems and confusion.** Both use the alternatives program to tell the system which *java* to use, but the OpenJDK packages are inconsistent in their alternatives priority settings and result in unintuitive installation results.
# Operating Systems
Trick runs on GNU/Linux and MacOSX, though any System V/POSIX compatible UNIX workstation should accept the Trick software with very little source code porting. Below are instructions for installing the prerequisites on popular operating systems here at NASA.
Trick requires the clang/llvm compiler to compile and link the Trick Interface Code Generator. clang/llvm is available through the [Extra Packages for Enterprise Linux](https://fedoraproject.org/wiki/EPEL) repository. Download and install the 'epel-release' package.
#UDUnits is required and is in the EPEL repository
yum install udunits2 udunits2-devel
```
The javac compiler must be installed. The javac compiler is included with the Java Development Kit (JDK). Trick will work with either the Oracle JDK or OpenJDK, but we prefer the Oracle JDK.
At the time of this writing (March 2015) the Oracle JDK 1.8 is available from the [Oracle download site](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html).
Trick makes use of several optional packages if they are present on the system. These include using the HDF5 package for logging, the GSL packages for random number generation, and google test (gtest) for Trick's unit testing. These are available from the EPEL repository
```bash
yum install hdf5-devel gsl-devel gtest-devel
```
---
<aname="redhat6"></a>
### RedHat Enterprise Linux (RHEL) 6
Trick requires gcc version 4.8+ to compile. gcc 4.9 is available through RHEL's [Software Collections](https://access.redhat.com/documentation/en/red-hat-software-collections/) capability. To install the software collections, the software collections reposotory needs to be added as a yum repository and the scl-utils package needs to be optionally installed. The instructions below are specific to Scientific Linux 6, an RHEL derivative. Repository location will be different for the official RHEL 6 and CentOS.
Trick requires the clang/llvm compiler to compile and link the Trick Interface Code Generator. clang/llvm is available through the [Extra Packages for Enterprise Linux](https://fedoraproject.org/wiki/EPEL) repository. Download and install the 'epel-release' package.
#UDUnits is required and is in the EPEL repository
yum install udunits2 udunits2-devel
```
The javac compiler must be installed. The javac compiler is included with the Java Development Kit (JDK). Trick will work with either the Oracle JDK or OpenJDK, but we prefer the Oracle JDK.
At the time of this writing (March 2015) the Oracle JDK 1.8 is available from the [Oracle download site](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html).
Trick makes use of several optional packages if they are present on the system. These include using the HDF5 package for logging, the GSL packages for random number generation, and google test (gtest) for Trick's unit testing. These are available from the EPEL repository
Be sure to install the Oracle JDK. Alternatively, install OpenJDK with this command:
```bash
dnf install java-1.8.0-openjdk-devel
```
Trick makes use of several optional packages if they are present on the system. These include using the HDF5 package for logging, the GSL packages for random number generation, and google test (gtest) for Trick's unit testing. These are available from the EPEL repository
```bash
dnf install hdf5-devel gsl-devel gtest-devel
```
---
<aname="ubuntu16.04"></a>
### Ubuntu 18.04/16.04/15.10
All packages required for Trick may be installed through apt-get.
Openmotif may install dependent packages that conflict with other installations, fontconfig and freetype. Use the following command to skip installing these packages if you encounter conflicts.
```bash
brew install --ignore-dependencies openmotif
```
---
<aname="macosx"></a>
### MacOSX 10.13/10.12/10.11
1. Install XCode from the App Store.
2. Download and install Command Line Tools for MacOSX by opening a terminal and running the following command.
Openmotif may install dependent packages that conflict with other installations, fontconfig and freetype. Use the following command to skip installing these packages if you encounter conflicts.
```bash
brew install --ignore-dependencies openmotif
```
To configure Trick with an older llvm (No longer needed now that llvm 6 works with Xcode 9.2).
```bash
brew install llvm@5
./configure --with-llvm=/usr/local/opt/llvm@5
```
---
<aname="windows10"></a>
### Windows 10 version 1803 and 1709
1. Install Ubuntu 18.04 in the Windows Linux Subsystem following these [instructions.](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide).
2. Open a bash shell and install the following packages
4. Install an X-windows server like [Xming.](https://sourceforge.net/projects/xming/?source=typ_redirect)
5. Ensure hostname resolves to an address.
```bash
# Get name of machine
hostname
# Get IP of name
hostname -i
# If hostname -i returns an error find IP address
ifconfig
# Add an entry to /etc/hosts to associate IP address to hostname "numeric.ip.address hostname"
sudo <edit_cmd> /etc/hosts
```
# Install Trick
## 1.) Clone Trick
The following commands will clone the Trick repository into a folder named *trick* in your home directory. You can install multiple copies of Trick in different locations to isolate your simulation environments from one another.
```bash
cd ${HOME}
git clone https://github.com/nasa/trick
```
## 2.) Configure Trick
Navigate to the *trick* directory you just created and run the *configure* script.
```bash
cd ${HOME}/trick
./configure
```
The *configure* script will generate makefiles and locate project dependencies automatically. It may be necessary to specify dependency paths manually. Run the following command to see the possible options *configure* will accept.
```bash
./configure --help
```
## 3.) Compile Trick
Now that Trick has been configured and a makefile has been generated, we can run *make* to compile Trick. To build Trick in 32-bit mode, first set the `TRICK_FORCE_32BIT` environment variable to `1`.
```bash
make
```
### Install Trick
You can also install Trick on your machine by running *sudo make install* after you compile Trick.
```bash
sudo make install
```
You will need super user privileges in order to copy files directly to the default **/usr/local** directory. This install directory can be modified with the configuration script.
## 4.) Optionally Update Your Environment
Gone are the days when you needed to set several environment variables to use Trick. Trick can now be used completely environmentlessly*. You no longer need to set `TRICK_HOME` and friends.
Trick still makes use of shell variables, but their existence is only required during simulation compilation and execution. If they are not set, Trick will infer them without polluting your environment. Furthermore, they will be available to any processes that are spawned as part of compilation or execution, so even your own tools may no longer need these variables to be manually set.
Similarly, Trick does not require its executables to be on your `PATH`, but you may find it convenient to add them if you prefer to not specify the full path to `trick-CP` every time you build a sim. They are located in `bin` under Trick's root directory. However, if you frequently work with multiple versions of Trick, it is often easier to use a full path than to keep changing an environment variable.
Finally, although setting `TRICK_CFLAGS` and `TRICK_CXXFLAGS` is not necessary, it can be useful to do so if you want a set of flags (`-g` or `-Wall`, for instance) to be applied to all simulation builds.
*The exception to this is if you're building in 32-bit mode, in which case the `TRICK_FORCE_32BIT` environment variable must be set to `1` before you build Trick or any simulation.
[Continue to Building A Simulation](../building_a_simulation/Building-a-Simulation)