In this how-to, we will be projecting our first hypermedia driven web application (HDA) built on the C++ Drogon web server with Ubuntu 22.04 Linux.
- A Linux OS
- Basic CLI Experience
- A C++ Package Manager like vcpkg
- C++20 Compiler
The Application Architecture
The backend is based on the very fast C++ web framework called Drogon.
The database in use is SQLite3, but this can be replaced; see more at:
A Deep Dive
If you would like to learn more about the details of what a hypermedia web application is, I recommend a book from Bigskysoftware that is freely available on the world wide web.
Brakmic also has extra tidbits on the hypermedia application we will be building today and is the one who originally created the C++ HDA; If you are using OSX or Windows, instructions will also be at the following link.
In this how-to, we are focusing on Linux.
Install Linux Dependencies
sudo apt install uuid-dev libcriterion-dev
Install C++ Packages
To install a package, simply invoke
vcpkg install PACKAGE_NAME.
drogon drogon[ctl] fmt argparse brotli zlib openssl sqlite3 soci[core] soci[sqlite3]
Clone the HDA with CPP
In a directory for application development, clone the example C++ HDA Brakmic created.
git clone https://github.com/brakmic/HDA_with_Cpp.git cd HDA_with_Cpp
Update the vcpkg_root
In a text editor of your choosing, open up the meson.build file in the root of the project and edit the following line.
vcpkg_root = '/home/username/vcpkg'
Then, update the triplet for Linux
triplet = 'x64-linux'
I created a patch on GitHub that fixes a couple of issues with the Linux build system; if for some reason the patch hasn't been merged into the main branch, you may copy the build.meson I created.
The patch adds where the location of criterion has been installed; see lines 106-126 via the patch-1.
You may view the debugging process I went through here:
Build & Compile the HDA
After the meson.build file has been updated, we build and compile the C++ HDA.
Run the Drogon Web Server
Goto your favorite web browser and open the localhost on port 8081.
Congrats, you have projected your first HDA built with C++ and served with Drogon's speedy web server!
From here, you may begin learning how to add your own html styling, database tables and other things like authentication. To learn more, I recommend learning more with Drogon at: https://github.com/drogonframework/drogon and joining the Telegram channel via https://t.me/joinchat/_mMNGv0748ZkMDAx .
Financial Support & Donations
I mainly debug code, drive, yak shave and deep dive into research for Linux base operating systems.
I am a Free Software Associate (FSF), privacy advocate and Cosmopolitan that enjoys philosophie, meta-physics, hacking and debugging computer hardware/software.
A Drogon C++ Web Server https://drogon.org/
A Hypermedia app example from Brakmic https://github.com/brakmic/HDA_with_Cpp
Artwork from Unsplash https://unsplash.com/@matiasmalka
Getting Started with vcpkg https://vcpkg.io/en/getting-started.html
Linux build issues and solutions https://github.com/brakmic/HDA_with_Cpp/issues/3
What is HTMX? https://htmx.org/
What are Hypermedia Systems? https://hypermedia.systems/