ADMB/TMB Full Installation for Windows
2 Overview
These procedures in the document install the following software and was tested on 5/20/2025:
R 4.5.0
Rtools 45 (for the CPP compilers)
RStudio 2025.05.0 Build 496
TMB package for R 1.9.17
ADMB 13.1
Emacs 27.2 (Emacs versions 28 and up will not work)
Emacs configuration files
- These files provide the syntax highlighting in Emacs for both ADMB and TMB and set up the Environment
admb2r.cpp in the ADMB folder
Appendix 1: User Environment PATH
2.1 Admin access to your computer
The installation procedures will do the following thatmight require more administrative access to your computer than your user account has:
Install programs (R, RStudio, Rtools, ADMB, Emacs)
Install programs directly to the C: drive (ADMB, RTools)
Install programs not validated by Microsoft (ADMB)
Run a batch file (PATH.bat)
4 Software Installation
You can use the default installation options for all applications.
Steps 1-4 are only needed for TMB, step 5 is only needed for ADMB, steps 6 and 7 are needed for both ADMB and TMB.
1) Download and Install R (you need to have at least version 4.3)
2) Download and install Rtools (you need to have at least version 43 and the version must match your R version)
- Click on Rrools4X Installer in Installing Rtools4X section
3) Download and install RStudio (you need to have a version from 2022 or later)
4) Open RStudio and install the TMB package
In RStudio: Tools ➔ Install Packages… ➔ type TMB in Packages textbox ➔ Install
Close RStudio after installing package
5) Download and install ADMB-13.1-windows.exe
Alternatively, you can download ADMB-12.3-windows.exe (under Windows header)
When installing, you will likely get a Windows protected your PC screen, if so:
click More info
click Run anyway
6) Download and install emacs-27.2-x86_64-installer.exe
7) Go to ADMB-TMB-Install GitHub page
Click on green Code button and choose Download Zip
- This will download a zipped file named ADMB-TMB-Install-main.zip
Unzip ADMB-TMB-Install-main.zip (right-click, Extract All then Extract).
Execute (double-click) Path.bat
You will likely get a Windows protected your PC screen, if so:
click More info
click Run anyway
If this does not work you can do this: Appendix 2: manually copy configuration files and admb2r.cpp (this link also includes more about the files)
8) Restart computer
- As far as I know, this step is not needed – but I keep it here just to be safe.
5 Have Emacs open TPL files by default (optional)
Right-click on any *.tpl file
- there is one in the folder you just extracted ➔ examples ➔ simple ➔ simple.tpl
Choose Open With
Windows 10:
At bottom, click Choose an app on your PC
The Path is: C:\Program Files\Emacs\x86_64\bin\runemacs.exe
Click Open
Click Always
Windows 11:
go to bottom and click on Choose another
At bottom, click Choose an app on your PC
The Path is: C:\Program Files\Emacs\x86_64\bin\runemacs.exe
Click OK
Note: the same procedures will work if you want emacs to be the default program for CPP files
6 Testing out ADMB
In folder you just unzipped, double-click emacs ➔ examples ➔ simple ➔ simple.tpl
Open simple.tpl in Emacs
Click Translate (button 1), Build (button 2), and Run (button 3)
- Make sure you wait for steps to complete
If the Emacs panels look like this after Run, then ADMB is properly installed:
7 Testing out TMB
In folder you just unzipped, double-click emacs ➔ examples ➔ mini ➔ mini.cpp
Open mini.cpp in Emacs
Click Clean (button 1), Compile (button 2), and Run (button 3)
Make sure you wait for each step to complete
Compile take a minute or two
If the Emacs panels look like this after Run, then TMB is properly installed:
7.1 Package inconsistency error
If you see this message when compiling a TMB program:
Warning message:
In checkMatrixPackageVersion() : Package version inconsistency detected.
TMB was built with «Matrix version 1.5.4.1»
Current «Matrix version is 1.5.4»
Please re-install 'TMB' from source using install.packages('TMB', type = 'source') or ask CRAN for a binary version of 'TMB' matching CRAN's 'Matrix' package
using C++ compiler: 'G__~1.EXE (GCC) 12.2.0'Do not follow the instructions given. Instead just update or reinstall the outdated package (in this case, Matrix). This is only necessary if the the script does not work because of the outdated package.
8 Appendix 1: User Environment PATH
The User Environment PATH variable is not needed anymore. I added this to the emacs configuration files.
However, there is still a chance that the User Environment PATH has been set by a previously installed program and that PATH could interfere with ADMB and TMB’s operation. This is most likely only going to be true if you previously installed ADStudio.
You can see the User Environment PATH by doing a Windows search for Environment and choosing Edit the system environment variables.
That will open the System Properties window on the Advanced tab– click on the Environment… button:
Then double-click on Path in the User variables section:
Delete any references to older versions of ADMB, TMB, or ADStudio. You can also safely delete the references to the current ADMB version – they are not needed.
9 Appendix 2: manually copy configuration files and admb2r.cpp
The extracted folder ADMB-TMB-Install-main contains:
An executable file called PATH.bat (which installs the folders and files below)
A folder called emacsConfigFiles that gets installed to the emacs folder when PATH.bat is executed
A folder called Examples, which contains ADMB and TMB scripts that are used in this document to test the installation.
admb2r.cpp – a commonly used ADMB script file that is not included with ADMB
PATH.bat is a batch file that copies the emacs configuration files and admb2r.cpp to the correct locations.
The following are instructions to manually copy the files – this is only needed if PATH.bat does not work.
9.1 Copy emacs configuration files
Inside ADMB-TMB-Install-main, there is a folder named emacsConfigFiles. You need to copy the contents inside the emacsConfigFiles folder (a file named .emacs and a folder named emacs) to the user’s appdata folder.
The easiest way to get to the user’s appdata folder is to type %appdata% in a File Explorer window and hit enter. Or, you can go directly to the folder: C:\Users\<yourUserName>\AppData\Roaming. Move both the emacs folder and .emacs file to this folder:
9.2 Copy admb2r.cpp
The file admb2r.cpp is used in ADMB scripts but it does not come with ADMB.
You can add it to ADMB by copying admb2r.cpp from the ADMB-TMB-Install-main folder to the following locations:
c:\ADMB-13.1\include
c:\ADMB-13.1\include\contrib (I am not sure it is necessary to copy it here)
Note: If you are using a different version of ADMB then replace 13.1 with the version you are using