sleepy-discord icon indicating copy to clipboard operation
sleepy-discord copied to clipboard

ObjectResponse Linking Error

Open alexgb0 opened this issue 2 years ago • 3 comments

Error

ObjectResponse (and many more probably) gives a linking error if the c++ standard is not higher than 17

It will be more convenient if it gives a proper error instead of giving a linking error. Because it took me a whole day to realize the problem.

alexgb0 avatar Aug 08 '21 18:08 alexgb0

What's the error message? Also this library is made for C++ 11. Sounds like a C++ standard mismatch between the library and your bot. I have no idea because I don't know what the error is. Also what do you mean by proper error?

yourWaifu avatar Aug 08 '21 18:08 yourWaifu

I get this error with set (CMAKE_CXX_STANDARD 11). It doesn't give any linking error with 17 nor 20

error LNK2019: unresolved external symbol "public: __cdecl SleepyDiscord::Channel::Channel(class std::basic_string_view<char,struct std::char_traits<char> > const &)" (??0Channel@SleepyDiscord@@QEAA@AEBV?$basic_string_view@DU?$char_traits@D@std@@@std@@@Z) referenced in function "public: __cdecl SleepyDiscord::ObjectResponse<struct SleepyDiscord::Channel>::operator struct SleepyDiscord::Channel(void)" (??B?$ObjectResponse@UChannel@SleepyDiscord@@@SleepyDiscord@@QEAA?AUChannel@1@XZ)
error LNK2019: unresolved external symbol "public: __cdecl SleepyDiscord::Server::Server(class std::basic_string_view<char,struct std::char_traits<char> > const &)" (??0Server@SleepyDiscord@@QEAA@AEBV?$basic_string_view@DU?$char_traits@D@std@@@std@@@Z) referenced in function "public: __cdecl SleepyDiscord::ObjectResponse<struct SleepyDiscord::Server>::operator struct SleepyDiscord::Server(void)" (??B?$ObjectResponse@UServer@SleepyDiscord@@@SleepyDiscord@@QEAA?AUServer@1@XZ)

alexgb0 avatar Aug 09 '21 10:08 alexgb0

Yeah, your library was compiled for C++ 17 and up. Which allows for the user of std::string_view, which isn't available in C++11. I think the error message is fairly clear. I can't really replace those errors, nor am I sure of a way to detect it. There might be a way to prevent the issue, maybe, but I currently don't know of a solution as of right now.

yourWaifu avatar Aug 09 '21 10:08 yourWaifu