DMD is a compiler for the D programming language. D is a high level, general purpose, statically typed language that has syntax similar to C/C++.
This tutorial explains how to install DMD on Ubuntu 24.04.
Install DMD
Get the latest version of DMD and assign it to variable.
D_VERSION=$(wget -qO - http://downloads.dlang.org/releases/LATEST)Download Debian package (.deb) of DMD from official page:
wget -qO dmd.deb http://downloads.dlang.org/releases/2.x/${D_VERSION}/dmd_${D_VERSION}-0_amd64.debRun the following commands to update the package lists and install DMD:
sudo apt updatesudo apt install -y ./dmd.debWhen installation is finished, we can check DMD version:
dmd --versionYou can remove .deb package because no longer needed:
rm -rf dmd.debTesting DMD
Create a file called main.d:
nano main.dPopulate file with the following lines of code:
import std.stdio;
void main()
{
    writeln("Hello world");
}Use dmd command to compile code:
dmd main.d -of=testIt builds a binary file named test. Now run it:
./testUninstall DMD
If you want to completely remove DMD and related dependencies, run the following command:
sudo apt purge --autoremove -y dmd 
             
                         
                         
                        
Leave a Comment
Cancel reply