[Regression] drogon::getVersion() compilation failed
Notice If you need support or clarification regarding the usage of Drogon in your project, visit the official Drogon support channel at gitter
Please create a new issue only if you think you have found a bug or if have a feature request/enhancement.
Describe the bug
error LNK2001: unresolved external symbol class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl drogon::getVersion(void)" (?getVersion@drogon@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
To Reproduce Steps to reproduce the behavior:
- Install drogon 1.7.5 with
vcpkg.json - compile the following code:
#include <drogon/drogon.h>
int main() {
LOG_INFO << drogon::getVersion();
return 0;
}
Expected behavior Program will compile
Desktop (please complete the following information):
- OS: Windows 11 21H2 22000.556
- Browser N/A
Additional context Compiler: MSVC 19.31.31104
I just started using the library and am experiencing a similar issue.
I've downloaded drogon 1.7.5 via vcpkg. I've followed the windows installation instructions. I setup a project using dragon_ctl. I'm using VS2019 with C++ 20
I'm getting a linker error when calling into certain functions like drogon::getVersion() or HttpResponse::getBody()
Error LNK2019 unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl drogon::getVersion(void)" (?getVersion@drogon@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function main
I've also tried using C++14 and boost and got the same linker error.
I have added the following to the path environment variables: vcpkg\installed\x64-windows\bin, lib and include
OS: Windows 10 10.0.19043 Visual Studio 2019 v16.11.7 MSVC 14.29.30133
the DROGON_EXPORT macro is missed with the getVersion function, I'll fix this issue by adding the macro.
Thank you for the prompt response and fix.
Any idea about the linker error with HttpResponse::getBody()?
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: class boost::basic_string_view<char,struct std::char_traits<char> > __cdecl drogon::HttpResponse::getBody(void)const " (__imp_?getBody@HttpResponse@drogon@@QEBA?AV?$basic_string_view@DU?$char_traits@D@std@@@boost@@XZ) referenced in function main
This seems to be a problem only when compiling with C++ 14 and boost. I don't see this error when using C++20. However my main project is stuck on C++14 for now.
Thank you for the prompt response and fix. Any idea about the linker error with
HttpResponse::getBody()?Error LNK2019 unresolved external symbol "__declspec(dllimport) public: class boost::basic_string_view<char,struct std::char_traits<char> > __cdecl drogon::HttpResponse::getBody(void)const " (__imp_?getBody@HttpResponse@drogon@@QEBA?AV?$basic_string_view@DU?$char_traits@D@std@@@boost@@XZ) referenced in function mainThis seems to be a problem only when compiling with C++ 14 and boost. I don't see this error when using C++20. However my main project is stuck on C++14 for now.
C++ 14 was checked in github CI actions. Try to clean your build folder and re-cmake, rebuild every thing.