GithubHelp home page GithubHelp logo

ct-open-source / micro-webservice Goto Github PK

View Code? Open in Web Editor NEW
7.0 6.0 5.0 103 KB

Micro-Webservice, implementiert mit Boost.Beast

License: GNU General Public License v3.0

CMake 13.03% C++ 86.97%
beast boost cplusplus educational-project webservice

micro-webservice's Introduction

c’t-Demo: Micro-Webservice

Für c’t-Leser

Dieses Repository enthält den Quellcode für den in c’t 7–9/2023 entwickelten Webservice. Um es auf Ihren Rechner zu bekommen, müssen Sie es klonen:

git clone https://github.com/ct-Open-Source/micro-webservice.git
cd micro-webservice

Der Code für den 1. Teil befindet sich im Branch „part1“. Sie checken ihn aus mit

git checkout part1

Der Code für den 2. Teil befindet sich im Branch „part2“. Sie checken ihn aus mit

git checkout part2

Der Code für den 3. Teil befindet sich im Branch „part3“. Sie checken ihn aus mit

git checkout part3

Vor dem Ausprobieren von Teil 3 unter Windows oder Windows Subsystem for Linux bitte Issue #4 beachten!

Systemvoraussetzungen

Der Webservice benötigt das Boost-Framework, das Sie wie folgt installieren können.

Ubuntu

sudo apt install libboost-dev

Ggf. sind noch die Pakete libblkid-dev, e2fslibs-dev, libboost-all-dev und libaudit-dev zu installieren.

macOS 13 Ventura

brew install libboost-dev

WSL/Windows 11

mkdir -p ~/tmp
cd ~/tmp
wget https://boostorg.jfrog.io/artifactory/main/release/1.82.0/source/boost_1_82_0.tar.gz
cd boost_1_82_0
./bootstrap.sh
./b2 cxxflags=-std=c++17
mkdir -p ~/dev
./b2 install --prefix=/home/<youruserid>/dev

Windows 11

Windows-Nutzer müssen die benötigten Bibliotheken Boost und GMP aus dem Quellcode übersetzen.

Boost

  • Quellcode der aktuellen Boost-Version (derzeit 1.82.0) herunterladen und entpacken
  • Im Visual Studio Developer Command Prompt in das entpackte Verzeichnis wechseln und dann eingeben:
bootstrap
md %HOMEPATH%\dev
b2 cxxflags=-std=c++17
b2 install --prefix=%HOMEPATH%\dev

GMP

git clone https://github.com/gx/gmp.git
cd gmp
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=%HOMEPATH%\dev ..
cmake --build . --config Release --target ALL_BUILD
cmake --build . --config Release --target RUN_TESTS
cmake --build . --config Release --target INSTALL
cd %HOMEPATH%\dev\gmp\lib
copy libgmp-13.lib gmp.lib
copy libgmpxx-9.lib gmpxx.lib

Webservice kompilieren

macOS, Linux

Zum Erzeugen der Build-Dateien kommt CMake zum Einsatz:

mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..

Wenn Sie statt eines Release ein Binary zum Debuggen erzeugen wollen, wählen Sie „Debug“ statt „Release“.

Falls CMake die Boost-Bibliothek nicht finden kann, müssen Sie den Pfad (beispielsweise /opt/boost-1_81_0) dorthin in der Umgebungsvariable BOOST_ROOT angeben:

BOOST_ROOT=/opt/boost-1_81_0

Nun können Sie den Compiler anwerfen:

cmake --build .

Es entsteht das Binary micro-webservice, das Sie mit

./micro-webservice

aufrufen können.

WSL/Windows 11

cd micro-webservice
mkdir -p build
cd build
BOOST_ROOT=~/dev/boost_1_82_0 cmake -DCMAKE_BUILD_TYPE=Release ..

Windows

cd micro-webservice
md build
cd build
set GMP_ROOT=%HOMEPATH%\dev\gmp
set BOOST_ROOT=%HOMEPATH%\dev\boost_1_82_0
cmake --fresh ..
cmake --build . --config Release

Bevor Sie die im Verzeichnis Release entstandene EXE-Datei micro-webservice.exe aufrufen können, müssen Sie noch die DLL der GMP-Bibliothek dorthin kopieren:

copy %HOMEPATH%\dev\gmp\bin\libgmp-13.dll Release

Copyright ©️ 2023 Oliver Lau, Heise Medien GmbH & Co. KG


Nutzungshinweise

Diese Software wurde zu Lehr- und Demonstrationszwecken geschaffen und ist nicht für den produktiven Einsatz vorgesehen. Heise Medien und der Autor haften daher nicht für Schäden, die aus der Nutzung der Software entstehen, und übernehmen keine Gewähr für ihre Vollständigkeit, Fehlerfreiheit und Eignung für einen bestimmten Zweck.

micro-webservice's People

Contributors

607011 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

micro-webservice's Issues

Build against Boost 1.81/1.182 fails

Ich versuche das Projekt auf meinem MacBookPro (BigSur 11.7.6) mit einem selbstgebauten Boost 1.81 zu erstellen. Für branch part2 war Boost 1.76 ausreichend, welches über MacPorts installiert werden konnte. Für branch part3 ist mindestens Boost 1.81 notwendig. Da mir Homebrew zu "schwerfällig" ist, bin ich schon länger auf MacPorts umgestiegen. Leider ist hier nur Boots 1.76 als package vorhanden. Deshalb habe ich Boost 1.81 als Archiv heruntergeladen, extrahiert und gebaut:

$ ./bootstrap.sh --prefx=...
$ ./b2 cxxflags=-std=c++17
$ ./b2 install

Mit export BOOST_ROOT=...wird der Basis-Ordner für die Boost Installation gesetzt. Damit bin ich dann ans Bauen gegangen:

micro-webservice/build ❯ cmake ..
-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at /opt/local/share/cmake-3.24/Modules/FindBoost.cmake:1384 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /opt/local/share/cmake-3.24/Modules/FindBoost.cmake:1507 (_Boost_COMPONENT_DEPENDENCIES)
  /opt/local/share/cmake-3.24/Modules/FindBoost.cmake:2118 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:10 (find_package)


CMake Warning at /opt/local/share/cmake-3.24/Modules/FindBoost.cmake:1384 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /opt/local/share/cmake-3.24/Modules/FindBoost.cmake:1507 (_Boost_COMPONENT_DEPENDENCIES)
  /opt/local/share/cmake-3.24/Modules/FindBoost.cmake:2118 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:10 (find_package)


CMake Warning at /opt/local/share/cmake-3.24/Modules/FindBoost.cmake:2217 (message):
  No header defined for url; skipping header check (note: header-only
  libraries have no designated component)
Call Stack (most recent call first):
  CMakeLists.txt:10 (find_package)


CMake Error at /opt/local/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Boost (missing: url) (found suitable version "1.81.0",
  minimum required is "1.81.0")
Call Stack (most recent call first):
  /opt/local/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /opt/local/share/cmake-3.24/Modules/FindBoost.cmake:2376 (find_package_handle_standard_args)
  CMakeLists.txt:10 (find_package)


-- Configuring incomplete, errors occurred!

Warum genau scheint hier etwas in der Boost Installation zu fehlen ?

boost für macOS

"brew install libboost-dev" hat auf meinem MacBook (es läuft unter Ventura) nicht funktioniert. Stattdessen muss es wohl "brew install boost" heißen.

Viele Grüße,
Peter Holl

Installationsanleitung für WSL2

Für WSL2 unter Windows 10 musste ich noch vorab installieren:
Boost 1.81 (standarmäßig wird 1.73 installiert. Das reicht nicht aus)
GMP (libgmp3-dev)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.