Creating a REST api in C plus plus

Posted By :Jayant Singh Parmar |1st April 2019

This blog consists of the following parts:

  1. Tool required for the setup

  2. Steps involved in the setup

  3. Points to remember

  4. Creating a basic cutelyst application


 

  1. Tools required for the setup : Following tools are required for the setup

  • Cutelyst Framework - source - https://github.com/cutelyst/cutelyst
  • CMake - for Windows x64 platform - https://cmake.org/download/
  • Qt 5.6 or higher - https://www.qt.io/download (Qt 5.12.0 in my case)
  • Visual Studio 2017 Community.
  • Microsoft Visual C++ compiler (MSVC 2017 32bit in my case)

Note: I assume that Visual Studio, Qt and CMake are already set up on your computer.

 

  1. Steps involved in the setup

  • Download the cutelyst source from the GitHub link provided above and unzip it to the following location “C:\cutelyst-2.7.0”
  • Create a folder named cutelyst_build in the same location “C:\cutelyst_build”

  • Now open CMake-GUI.

Note: Open CMake-GUI with admin rights to avoid errors due to access permissions

  • Provide source(C:\cutelyst-2.7.0) and build(C:\cutelyst_build) paths.??
  • Now click on the Configure button and select MS Visual Studio 2017 as a generator and select “Use native compilers” and then click OK.
  • At this, you will get some errors but don’t worry just look for the red values, update them and then again click on Configure button

Note: The possible errors at this point may be regarding the paths of  Qt5 and Cutelyst2Qt5. Just update the following entries in the CMake as mentioned below.

Qt5_DIR => “C:\Qt\5.12.0\msvc2017\lib\cmake\Qt5”

Cutelyst2Qt5_DIR => “C:\cutelyst_build\Cutelyst\Debug”

Create a folder named cutelyst in “C:\Program Files(x86)” and then click on Configure, you will see “Configuration done” in the output window in the CMake-GUI.

 

  • Click on Generate button and you will see “Generating done” message in the CMake-GUI output window.
  • Now open Qt 5.12.0 (MSVC 2017 - 32bit) command prompt with admin rights and navigate to your cutelyst build folder “C:\cutelyst_build”  and run the following command

        cmake -- build. --config Release

                 Once build is finished then run the following command

        cmake -- build. --target INSTALL --config Release

                 That’s it, cutelyst installation is done.

 

  1. Points to remember

  • Install all the required tools before starting the installation.
  • Open all the tools with admin rights to avoid errors regarding access permissions.
  • Source and build paths should not contain any spaces
  • Make sure you select the appropriate Qt version and C++ compiler.

Qt 5.12.0 and MSVC 2017(32bit) in my case

  • Same version(as of C++ compiler) of Visual Studio should be installed on your computer prior to installation

 

  1. Creating a basic cutelyst application

  • Before creating an application add the following path variable to your system settings “C:\Program Files (x86)\cutelyst\bin”
  • In the MSVC command prompt navigate to your desired location(say C:\Cutelyst_Apps) and run the following command cutelyst2 --create-app Hello

A folder Hello will be created inside the Cutelyst_App folder.

  • Navigate to “C:\Cutelyst_Apps\Hello\build” and run the following command

                  cmake --build . --config Debug

                  Now the libraries will be generated inside the following path

                  “C:\Cutelyst_Apps\Hello\build\src\Debug”

                  Note: If you can't find the build folder you can create it manually

 

  • Navigate to “C:\Cutelyst_Apps\Hello” and run the following command

cutelyst2 -r --server --app-file .\build\src\Debug\Hello.dll

 

  • Test the application by running the url “localhost:3000” in your web browser. You will see the message “Welcome to Cutelyst!” in your web browser.

That’s it, cutelyst app created successfully.

 

About Author

Jayant Singh Parmar

Jayant has more than 5+ years of industry experience as a frontend developer. He has good knowledge of technologies like Angular, reactJS, HTML, CSS, javascript etc. He is proficient in building complex UI designs, implentation of complex logics on frontend, API integrations, development and deployments and have been part of successfully delivering services on various client projects like Virgin Media, Hp1t and Jabburr He is a quick learner and keen to learn new technologies.

Request For Proposal

[contact-form-7 404 "Not Found"]

Ready to innovate ? Let's get in touch

Chat With Us