Building APSIM from source
All Apsim sources are available form the github repository.
Microsoft Visual Studio (2017 or 2019) is used to build both Apsim Classic and Next Generation. The (free on registration) Community Edition will suffice.
Git: you will need at least a command line git client installed on your system, and you may feel comfortable using a GUI such as TortoiseGit to examine changes to the source tree. There are several described here.
Compiling ApsimClassic
1. Clone the repository:
git clone https://github.com/APSIMInitiative/APSIMClassic
2. Install 7Zip, download the build library and unpack it alongside the repository.
7z x BuildLibraries.7z
3. Install a 32 bit GNU fortran 7.x compiler (or any non-cygwin binary distribution). This package also includes GNU make, which is used by the builder. A zip archive is available here.
The unit tests require NUnit 2.x.
The cotton module will not build unless the password is obtained from the module owner.
To build the GUI, you will need two commercial products: TeeChart for .NET component, and the Quantum Whale editor component.
To build the R component, you will need R installed, and the extensions RCpp, RInside.
4. Open the Visual Studio 2017/9 Developer command prompt, and change to …/APSIMClassic/Model/Build. Run the command “BuildAll.bat” in that directory.
Compiling ApsimX
1. (ApsimX) Clone two repositories into adjacent directories:
git clone https://github.com/APSIMInitiative/APSIM.Shared
and
git clone https://github.com/APSIMInitiative/ApsimX
2. Open APSIM.Shared\APSIM.Shared.sln file with the Microsoft Visual Studio desktop app and build it.
3. Copy the ApsimX deployment support files “ApsimX\DeploymentSupport\Windows\Bin64\*” to the runtime directory “ApsimX\Bin\”
4. Build ApsimX\ApsimX.sln with the Visual Studio desktop app.
Linux
The linux build of ApsimClassic uses the mono runtime for .NET components. Unfortunately, recent (5,6.x) versions of the runtime have proved unstable, so an older version (4.8.1) is recommended. On debian systems, this involves adding keys and repositories (as root):
gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-key E084DAB9 gpg -a --export E084DAB9 | apt-key add - gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-key A6A19B38D3D831EF gpg -a --export A6A19B38D3D831EF | apt-key add - echo "deb http://download.mono-project.com/repo/debian wheezy/snapshots/4.8.1 main" > /etc/apt/sources.list.d/mono.list echo "deb http://mirror.aarnet.edu.au/pub/CRAN/bin/linux/ubuntu bionic-cran35/" > /etc/apt/sources.list.d/cran.list apt-get update && apt-get -y install \ g++ gfortran libgfortran3 \ libxml2 libxml2-dev tcl8.5 tcllib curl \ mono-devel mono-vbnc mono-runtime \ r-base r-base-dev r-recommended Rscript -e "install.packages(c(\"Rcpp\",\"RInside\"))"
Although the GUI components can be built and run under Linux, they are not fully operational, and are not supported by the APSIM development team. If you wish to experiment with the GUI, you may need to make a few changes to enable Mono on Linux to emulate the Windows registry. This can be done with the following commands:
sudo mkdir /etc/mono/registry
sudo mkdir /etc/mono/registry/ClassesRoot
sudo chmod 777 /etc/mono/registry -R
For building ApsimX on linux, see the github notes