Skip to content

csabika98/wtAppCPP

Repository files navigation

HelloWtApp2

Screenshots

1

1.png

2

2.png

3

3.png

Installation

Pre-requirements:

Wt is required to run the web app.

FOR LINUX

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
  1. Clone Wt
git clone https://github.com/emweb/wt.git
  1. Create a build directory
mkdir build
cd build
  1. Configure the library:
cmake ../
  1. Build the library
make -j4
  1. 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)

Overview

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.

Project Structure

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

Prerequisites

  • CMake 3.10 or higher
  • A C++ compiler that supports C++17
  • Wt libraries and their dependencies (e.g., Boost, OpenSSL)

Building the Application

  1. Clone the repository:
git clone https://github.com/csabika98/HelloWtApp2.git
cd HelloWtApp2
  1. Create a build directory and navigate into it:
mkdir build 
cd build
  1. Run CMake to configure the project:
cmake ..
  1. Build the project:
cmake --build .

Running the Application

After building the application, you can run the executable with the following command:

./bin/HelloWtApp2 

This command starts the server on http:https://localhost:8080 and serves the application.

Project Configuration

CMake Configuration

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages