r/cpp • • Mar 09 '23

Removed - Help Compiling CrowCPP on Windows and about to kms

[removed] — view removed post

0 Upvotes

7 comments sorted by

•

u/Flair_Helper Mar 10 '23

For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.

This post has been removed as it doesn't pertain to r/cpp: The subreddit is for news and discussions of the C++ language and community only; our purpose is not to provide tutoring, code reviews, or career guidance. If you think your post is on-topic and should not have been removed, please message the moderators and we'll review it.

3

u/Pupper-Gump Mar 09 '23

I just tried building it with cmake and it's saying "project files may be invalid". I'd just pick apart the pieces you need from their code rather than trying to link everything.

4

u/tjin19 Mar 09 '23

Thanks for the advice :)I have since given up and using httplib

https://github.com/yhirose/cpp-httplib

which works.

5

u/delta_p_delta_x Mar 09 '23 edited Mar 09 '23

I have no issues with CrowCpp on Windows, using the x64-windows triplet and a fresh clone of vcpkg and a fresh install of the crow port. Here is what I did; perhaps it might help.

  1. Ensure you have Visual Studio 2022 with the Desktop Development with C++ workload installed. Or, get the Build Tools for Visual Studio 2022 and also install a similar workload.

  2. Open the Developer PowerShell for VS 2022.

  3. Navigate to some new empty directory, e.g.:

     > ni -Type Directory crowtest
     > cd crowtest
  4. Issue the following commands:

     > git clone https://github.com/microsoft/vcpkg.git
     > .\vcpkg\bootstrap-vcpkg.bat -disableMetrics
     > .\vcpkg\vcpkg.exe install crow 
  5. This should automatically pull in Crow and its dependencies, and build it all for you.

  6. Create CMakeLists.txt in this directory (ni CMakeLists.txt) with the following content:

     cmake_minimum_required(VERSION 3.25)
     
     project(crowtest)
     
     find_package(Crow CONFIG REQUIRED)
     
     add_executable(crowtest main.cpp)
     target_link_libraries(crowtest PRIVATE Crow::Crow)
  7. Create CMakePresets.json in this directory (ni CMakePresets.json) with the following content:

     {
         "version": 3,
         "cmakeMinimumRequired": {
             "major": 3,
             "minor": 25,
             "patch": 0
         },
         "configurePresets": [
             {
                 "name": "default",
                 "generator": "Ninja",
                 "binaryDir": "${sourceDir}/build/${presetName}",
                 "cacheVariables": {
                     "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake"
                 },
                 "architecture": {
                     "value": "x64",
                     "strategy": "external"
                 }
             }
         ],
         "buildPresets": [
             {
                 "name": "default-build",
                 "configurePreset": "default"
             }
         ]
     }
  8. Create main.cpp in this directory (ni main.cpp) with the following content:

     #include <crow.h>
     
     auto main() -> int {
         crow::SimpleApp app{};
    
         CROW_ROUTE(app, "/")([] {
             return "Hello world";
         });
    
         app.port(18080).multithreaded().run();
     }
  9. Issue the following commands:

     > cmake.exe --preset default 
     > cmake --build --preset default-build
     > .\build\default\crowtest.exe
     (2023-03-09 13:02:05) [INFO    ] Crow/1.0 server is running at http://0.0.0.0:18080 using 16 threads
     (2023-03-09 13:02:05) [INFO    ] Call `app.loglevel(crow::LogLevel::Warning)` to hide Info level logs.
  10. Fire up a new PowerShell instance to test, and issue the following:

     > Invoke-RestMethod -Method Get -Uri http://localhost:18080
     Hello world
     (2023-03-09 13:06:01) [INFO    ] Request: 127.0.0.1:4896 000002A736A54C80 HTTP/1.1 GET /
     (2023-03-09 13:06:01) [INFO    ] Response: 000002A736A54C80 / 200 0

1

u/tjin19 Mar 10 '23

great work man.. will try if needed!

1

u/prince-chrismc Mar 10 '23

There's a ton of great HTTP frameworks. Personally my fav is RESTinio.

This project has gone through many phases this is a fork the revived the original version of crow.

It's available in Conan too https://github.com/conan-io/conan-center-index/tree/master/recipes/crowcpp-crow though it's not well maintained so no promises if it's working

It pasted the windows build 2 months ago :)

0

u/[deleted] Mar 09 '23

[deleted]

1

u/HeeTrouse51847 Mar 09 '23

the meme is real