Prerequisites for Mobilis Code Building
A comprehensive guide to setting up a modern development environment across Ubuntu (including WSL), macOS, Windows, and Cygwin. This updated guide covers installation instructions, environment setup, and necessary tools to build code efficiently on various platforms.
Prerequisites for Mobilis Code Building
This guide provides detailed instructions to set up the development environment for building and deploying Mobilis, a C++ simulator developed at the City Science Lab of the University of Bologna. Mobilis is used to simulate traffic flows in a graph, and it requires specific tools and configurations to function correctly.
The following steps outline how to configure your development environment on various platforms, including Ubuntu (with or without WSL on Windows), macOS, Windows (10/11), and Cygwin. These instructions ensure that all necessary tools and dependencies are installed so that you can efficiently build and deploy Mobilis on your machine.
Follow the steps for your platform to get started with the simulation project.
Ubuntu on Windows (WSL)
For users running Ubuntu via Windows Subsystem for Linux (WSL) on Windows 10/11, follow these steps:
- Install and Update WSL:
- Ensure you have WSL 2 installed. If not, follow the official Microsoft WSL installation guide.
- Install Chocolatey (if not already installed):
- Refer to Chocolatey.org for installation instructions.
- Install an X Server (for GUI applications):
- Windows 10: Install VcXsrv using Chocolatey. Open PowerShell as Administrator and run:
cinst -y vcxsrv
- Windows 11: WSLg supports Linux GUI applications natively, so an external X server is typically not required.
- Windows 10: Install VcXsrv using Chocolatey. Open PowerShell as Administrator and run:
- Launch the X Server:
- If using VcXsrv, run it and keep it open whenever you need graphical support in WSL.
- Configure the DISPLAY Variable:
- In your Ubuntu (WSL) terminal, add the following to your
~/.bashrc
(or~/.zshrc
if using Zsh):1 2
echo -e "\nexport DISPLAY=localhost:0.0\n" >> ~/.bashrc source ~/.bashrc
- In your Ubuntu (WSL) terminal, add the following to your
- Proceed with the Ubuntu setup below.
Ubuntu
- Create a Workspace Directory:
- Define a work folder (e.g.,
~/code
or another preferred location). Note its full path (e.g.,/home/yourusername/code
).
- Define a work folder (e.g.,
- Set the WORKSPACE Environment Variable:
- Open a terminal and run (replace
/full/path/to/my/folder
with your folder’s full path):1 2
echo -e "\nexport WORKSPACE=/full/path/to/my/folder\n" >> ~/.bashrc source ~/.bashrc
- Open a terminal and run (replace
- Update Your System:
1 2
sudo apt-get update sudo apt-get dist-upgrade
- Install Essential Development Tools and Libraries:
1 2 3 4
sudo apt-get install -y g++ cmake make git dos2unix ninja-build git config --global core.autocrlf input git clone https://github.com/physycom/sysconfig sudo apt-get install -y libboost-all-dev libfltk1.3-dev freeglut3-dev libgl1-mesa-dev libglu1-mesa-dev libxinerama-dev libjpeg-dev libxi-dev libxmu-dev libcurl4-openssl-dev
- Verify and Update CMake (if necessary):
- Check the installed version:
1
cmake --version
- If the version is older than 3.20, consider installing a newer version. For example, for Linux 64-bit:
1 2 3 4 5 6 7 8 9
cd $WORKSPACE export CMAKE_FULL_VERSION="cmake-3.27.0-Linux-x86_64" export CMAKE_VERSION="v3.27" mkdir -p cmake cd cmake wget https://cmake.org/files/${CMAKE_VERSION}/${CMAKE_FULL_VERSION}.tar.gz tar zxvf ${CMAKE_FULL_VERSION}.tar.gz echo -e "\nexport PATH=${WORKSPACE}/cmake/${CMAKE_FULL_VERSION}/bin:\$PATH\n" >> ~/.bashrc source ~/.bashrc
- Your Ubuntu environment is now ready for code building.
macOS
- Install Xcode Command Line Tools:
1
xcode-select --install
- Install Homebrew (if not already installed):
- Follow the instructions on the Homebrew website.
- Update Homebrew and Install Required Packages:
1 2 3 4 5
brew update && brew upgrade brew install cmake make git dos2unix ninja git config --global core.autocrlf input git clone https://github.com/physycom/sysconfig brew install fltk boost freeglut
- Create a Workspace Directory:
- Define your workspace (e.g.,
~/code
).
- Define your workspace (e.g.,
- Set the WORKSPACE Environment Variable:
- Open Terminal and run (replace
/full/path/to/my/folder
with your workspace path):1 2
echo -e "\nexport WORKSPACE=/full/path/to/my/folder\n" >> ~/.bash_profile source ~/.bash_profile
- Open Terminal and run (replace
Windows (10/11)
- Install Visual Studio:
- Install or update to Visual Studio. Ensure it is fully updated.
- Install Chocolatey (if not already installed):
- Follow the instructions on Chocolatey.org.
- Install Required Tools via Chocolatey:
- Open
PowerShell
with Administrator privileges and run:1
cinst -y git cmake powershell ninja
- Restart your PC if prompted.
- Open
- Set PowerShell Execution Policy:
- In an Administrator PowerShell, run:
1
Set-ExecutionPolicy RemoteSigned
- In an Administrator PowerShell, run:
- Create a Workspace Directory:
- Create a folder for your code (e.g.,
C:\Code
).
- Create a folder for your code (e.g.,
- Configure Environment Variables:
- Open a standard user PowerShell and run:
1
rundll32 sysdm.cpl,EditEnvironmentVariables
- Add or update the following variables:
1 2 3
WORKSPACE → full path of your workspace. VCPKG_ROOT → %WORKSPACE%\vcpkg VCPKG_DEFAULT_TRIPLET → x64-windows-physycom
- Ensure the following is added to your PATH:
1
%PROGRAMFILES%\CMake\bin
- Open a standard user PowerShell and run:
- Clone the sysconfig Repository:
- In a standard user PowerShell, run:
1 2 3
cd $env:WORKSPACE git config --global core.autocrlf input git clone https://github.com/physycom/sysconfig.git
- In a standard user PowerShell, run:
- Install vcpkg (if not already installed):
1 2 3 4 5
cd $env:WORKSPACE git clone https://github.com/Microsoft/vcpkg.git cd vcpkg cp ..\sysconfig\cmake\x64-windows-physycom.cmake .\triplets\ .\bootstrap-vcpkg.bat
- Integrate vcpkg with Visual Studio:
- Open an Administrator PowerShell and run:
1 2
cd $env:WORKSPACE\vcpkg .\vcpkg integrate install
- Open an Administrator PowerShell and run:
- Install Necessary Libraries via vcpkg:
- In a standard user PowerShell, run:
1 2 3
cd $env:WORKSPACE\vcpkg .\vcpkg install fltk fltk:x86-windows-static boost boost:x86-windows-static freeglut freeglut:x86-windows-static opengl opengl:x86-windows-static rmdir .\buildtrees\ /s /q
- In a standard user PowerShell, run:
- Update Software:
- To update Chocolatey packages, open an Administrator PowerShell and run:
1
cup all -y
- To update Chocolatey packages, open an Administrator PowerShell and run:
- To update libraries in vcpkg:
1 2 3 4 5
cd $env:WORKSPACE\vcpkg git pull .\bootstrap-vcpkg.bat .\vcpkg update .\vcpkg upgrade --no-dry-run
Cygwin
- Install Chocolatey (if not already installed):
- Follow the instructions on Chocolatey.org.
- Install Cygwin via Chocolatey:
- Open PowerShell with Administrator privileges and run:
1
cinst -y cygwin
- Open PowerShell with Administrator privileges and run:
- Create a Workspace Directory:
- Create a folder for your code (e.g.,
C:\Code
).
- Create a folder for your code (e.g.,
- Set the WORKSPACE Environment Variable:
- Open a standard user PowerShell and run:
1
rundll32 sysdm.cpl,EditEnvironmentVariables
- Add a new variable named
WORKSPACE
with the full path of your workspace.
- Open a standard user PowerShell and run:
- Install Required Cygwin Packages:
- Open a standard user PowerShell, navigate to your workspace, and run:
1 2 3 4
cd $env:WORKSPACE Invoke-WebRequest https://cygwin.com/setup-x86_64.exe -OutFile $env:WORKSPACE\cygwin-setup.exe .\cygwin-setup.exe --quiet-mode --no-shortcuts --no-startmenu --no-desktop --upgrade-also --packages gcc-g++,cmake,git,dos2unix,libboost-devel,libfltk-devel,libglut-devel,libGL-devel,libGLU-devel,fluid,libjpeg-devel,libXi-devel,libXmu-devel git clone https://github.com/physycom/sysconfig.git