drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.44k stars 1.1k forks source link

[WIN32] Exception on addListener. Crashing in "_Emplace_reallocate" on emplace_back. used VCPKG. #1533

Closed bernardopadua closed 1 year ago

bernardopadua commented 1 year ago

Describe the bug I create a project in VSSTUDIO 2022. Wrote the default code below. 1

To Reproduce Steps to reproduce the behavior:

  1. Create a project in vsstudio 2022 (community)
  2. Wrote the code above (img).
  3. Installed vcpkg.
  4. Run cmd: vcpkg.exe install drogon
  5. It generated all dependecies and drogon.dll (+ libs)
  6. Configurated my project to c++17
  7. Add the additional lib and include paths
  8. Add the additional dependencies in Linker: drogon.dll
  9. Copied all dlls from vcpkg/installed/x86-windows/bin/*.dll to my Debug .exe DrogonTest.exe (copied to same folder)
  10. Tried to run the application and it crashed trying to addListener, guess it crashed on emplace_back the listener.

Don't know if I played dumb and forgot to change or add something somewhere... sorry.

Desktop (please complete the following information):

an-tao commented 1 year ago

You'd better to install drogon by vcpkg install drogon[ctl]:x64-windows and use the drogon_ctl create project command to create your project.

bernardopadua commented 1 year ago

Hello @an-tao.. Thanks for your reply.. Im still strugling to build without errors, I dont know if your main dev scenario is Windows. I did use drogon_ctl, but I`m having problems similarly to this one: https://github.com/drogonframework/drogon/issues/1208

I'm getting this error: image

I've successfully added drogon.lib to the project linker input, but still getting the error above. If you know anything to help I would appreciate. Thanks in advance.

an-tao commented 1 year ago

Did you open the project created by drogon_ctl as a CMake project?

bernardopadua commented 1 year ago

Hey @an-tao.. Yes, indeed I did. I've generated the project via cmake. I included from drogon source the function drogon_create_views that was missing for projects that was generated without compiling source manually and have used vcpkg for example...

I will try to compile source generating with dependencies... but in the meanwhile I will try to continue use it with vcpkg generated lib and include files. The problem of unresolved symbol is very strange cause I included the drogon.lib in the linker option... Don't know why.. in my project manually I had the same unresolved symbol problem and I was able to solve including drogon.lib in "input" option of project in vsstudio.

Any ideas what could be wrong ? thanks in advance..

an-tao commented 1 year ago

You don't need to manually add the Drogon library for linking. CMake will handle the project dependencies for you. Please refer to the relevant documentation on using CMake projects with MSVC. You can google keywords like cmake, msvc, vcpkg to get more information.

bernardopadua commented 1 year ago

After some tweaking in the project I was able to compile successfully. CMake didn't generate automatically for C++17, changed this and added manually the drogon lib solved the problem. And of course check compiled packages by vcpkg x64 or x86.

Thanks an-tao!