Since I really don’t want to go back to Windows, the bulky, messy headache, I decided to set up my QuantLib C++ development environment on Ubuntu. It took a few extra steps compared to setting up Visual Studio on Windows, so I’m sharing the process in this blog post in case it helps anyone.
Step 1 – Install Ubuntu if you don’t have one yet
Step 2 – Install Required Packages
Open a terminal and run the following bash commands to install the following required packages:
- build-essential package containing the C++ compiler
- cmake package for building the QuantLib C++ project
- automake, autoconf and libtool packages required for running the autogen.sh scripts later
- libboost-all-dev package for the Boost C++ libraries on linux-based systems
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install cmake
sudo apt-get install automake autoconf libtool
sudo apt-get install libboost-all-dev
Step 3. Install VS Code and Extensions
The VS Code can be installed following this official guide here, or installed from “Unbuntu Software”.
Once VS Code is installed, you can add extensions to support your C++ development. The main ones are: C/C++ by Microsoft and the CMake Tools extension.
Step 4. Install QuantLib
You can find the official guide of QuantLib installation on Linux here.
Here are the route and steps I took:
1) Check out QuantLib source code from https://github.com/lballabio/QuantLib.git
2) Under the QuantLib root directory, run the following commends (one by one):
./autogen.sh
./configure
3) Run the following commends to make and install QuantLib
make
sudo make install
sudo ldconfig
Step 5. Configure VS code building task
Create a tasks.json file under .vscode folder with the following settings. If you installed QuantLib following the same steps I listed above, nothing needs to be changed. One note here: don’t forget to add -lQuantLib in the args for linking the QuantLib library.
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${fileDirname}/*.cpp",
"-o",
"${fileDirname}/bin/${fileBasenameNoExtension}",
"-lQuantLib"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: /usr/bin/g++"
}
]
}
Step 6. Configure VS debugger
Create a launch.json file under .vscode folder with the following settings. The type needs to be “cppdbg”, MIMode to be “gdb”, and the preLaunchTask to be the label attribute of the building task created above.
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) C++ Launch",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/bin/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file"
}
]
}
End
Now, the dev environment is up and running. We can test it by setting a break point somewhere can run the debugger.


Out of curiosity with this approach are you able to debug core quant lib code i.e the actual .cpp files?
I am using VS Code as well on MacOs I set up the task.json and launch.json in a similar way but when I debug the Examples/CDS/CDS.cpp for example I can’t go inside:
Date settlementDate(18,September,2008) , i.e in date.cpp
Besides this the code runs fine and produces the correct result.