Wt is required to run the web app.
One command:
sudo apt update && sudo apt install gcc g++ cmake libboost-all-dev libssl-dev libhpdf-dev libgraphicsmagick1-dev libpango1.0-dev libpq-dev libmysqlclient-dev libmariadb-dev unixodbc-dev libunwind-dev zlib1g-dev firebird-dev libfcgi-dev libqt5core5a libqt5gui5 libqt5widgets5 libqt5sql5
Configuring g++ and gcc with alternatives, and setting C++14:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-<version> 60 \
&& sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-<version> 60 \
&& echo 'export CXXFLAGS="$CXXFLAGS -std=c++14"' | sudo tee /etc/profile.d/gcc.sh \
&& echo 'export CFLAGS="$CFLAGS -std=c++14"' | sudo tee -a /etc/profile.d/gcc.sh \
&& source /etc/profile.d/gcc.sh
Compiler:
sudo apt update
sudo apt install gcc g++
Cmake:
sudo apt update
sudo apt install cmake
C++ Boost Library:
sudo apt update
sudo apt install libboost-all-dev
OpenSSL:
sudo apt update
sudo apt install libssl-dev
Haru Free PDF Library:
sudo apt update
sudo apt install libhpdf-dev
GraphicsMagick:
sudo apt update
sudo apt install libgraphicsmagick1-dev
Pango:
sudo apt update
sudo apt install libpango1.0-dev
PostgreSQL:
sudo apt update
sudo apt install libpq-dev
MySQL:
sudo apt update
sudo apt install libmysqlclient-dev
MariaDB:
sudo apt update
sudo apt install libmariadb-dev
unixODBC:
sudo apt update
sudo apt install unixodbc-dev
libunwind:
sudo apt update
sudo apt install libunwind-dev
zlib for Compression:
sudo apt update
sudo apt install zlib1g-dev
firebird:
sudo apt update
sudo apt install firebird-dev
Libraries for wtfcgi and Qt for libwtwithqt Interoperability Layer:
sudo apt update
sudo apt install libfcgi-dev
sudo apt install libqt5core5a libqt5gui5 libqt5widgets5 libqt5sql5
Configure g++ and gcc
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-<version> 60
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-<version> 60
Set c++14:
sudo nano /etc/profile.d/gcc.sh
export CXXFLAGS="$CXXFLAGS -std=c++14"
export CFLAGS="$CFLAGS -std=c++14"
source /etc/profile.d/gcc.sh
- Clone Wt
git clone https://github.com/emweb/wt.git
- Create a build directory
mkdir build
cd build
- Configure the library:
cmake ../
- Build the library
make -j4
- Install the library
make install
CmakeList example:
cmake_minimum_required(VERSION 3.28)
project(dbo_test)
set(CMAKE_CXX_STANDARD 17)
project(dbo_test VERSION 1.0 LANGUAGES CXX)
file(GLOB_RECURSE SOURCES
${CMAKE_SOURCE_DIR}/src/*.cpp
${CMAKE_SOURCE_DIR}/src/*.c
${CMAKE_SOURCE_DIR}/docroot/resources/*.css
${CMAKE_SOURCE_DIR}/src/*.h
${CMAKE_SOURCE_DIR}/docroot/resources/*.html
${CMAKE_SOURCE_DIR}/docroot/resources/*.js
${CMAKE_SOURCE_DIR}/docroot/resources/*.c
${CMAKE_SOURCE_DIR}/docroot/*.html
${CMAKE_SOURCE_DIR}/docroot/*.js
${CMAKE_SOURCE_DIR}/docroot/*.css
${CMAKE_SOURCE_DIR}/src/controller/*.cpp
${CMAKE_SOURCE_DIR}/src/controller/*.c
${CMAKE_SOURCE_DIR}/src/controller/*.h
${CMAKE_SOURCE_DIR}/src/model/*.cpp
${CMAKE_SOURCE_DIR}/src/model/*.c
${CMAKE_SOURCE_DIR}/src/model/*.h
${CMAKE_SOURCE_DIR}/src/view/*.cpp
${CMAKE_SOURCE_DIR}/src/view/*.c
${CMAKE_SOURCE_DIR}/src/view/*.h
)
INCLUDE_DIRECTORIES(/usr/local/include)
add_executable(dbo_test ${SOURCES})
TARGET_LINK_LIBRARIES(dbo_test wt wthttp wtdbo wtdbosqlite3)
HelloWtApp2 is a web application built in C++.
This application demonstrates how to set up a simple server that serves an HTML template with embedded CSS.
myapp/
├── src/
│ ├── main.cpp
│ └── (other source files)
├── include/
│ └── (header files)
├── docroot/
│ └── resources/
│ ├── index.html
│ ├── themes/
│ │ └── default/
│ │ └── wt.css
│ ├── webkit-transitions.css
│ └── (other resource files)
├── lib/
│ └── (library files)
├── bin/
│ └── (DLL files)
├── CMakeLists.txt
└── README.md
- CMake 3.10 or higher
- A C++ compiler that supports C++17
- Wt libraries and their dependencies (e.g., Boost, OpenSSL)
- Clone the repository:
git clone https://github.com/csabika98/HelloWtApp2.git
cd HelloWtApp2
- Create a build directory and navigate into it:
mkdir build
cd build
- Run CMake to configure the project:
cmake ..
- Build the project:
cmake --build .
After building the application, you can run the executable with the following command:
./bin/HelloWtApp2
This command starts the server on http://localhost:8080 and serves the application.
The CMakeLists.txt file is configured to:
- Set the project name and version.
- Specify the C++ standard to be used (C++17).
- Include necessary directories.
- Recursively gather source files from the src and docroot/resources directories.
- Create an executable named HelloWtApp2.
- Link necessary libraries.
- Set the runtime output directory.
- Copy necessary DLLs to the output directory after the build.