yourWaifu / sleepy-discord

C++ library for the Discord chat client. Please use Rust for new bots
https://yourWaifu.github.io/sleepy-discord/
MIT License
707 stars 95 forks source link

'VER_MAJORVERSION' was not declared in this scope #101

Closed jedenastka closed 6 years ago

jedenastka commented 6 years ago

When I trying to buld this:


#include "sleepy_discord/websocketpp_websocket.h"

class myClientClass : public SleepyDiscord::DiscordClient {
public:
    using SleepyDiscord::DiscordClient::DiscordClient;
    void onMessage(SleepyDiscord::Message message) {
        if (message.startsWith("hello bot"))
            sendMessage(message.channelID, "Hi " + message.author.username);
    }
};

int main() {
    myClientClass client("XXXXXXXXXXX", 2);
    client.run();
}

with Code::Blocks, I get this list of errors:

||=== Build: Debug Win32 in hello (compiler: GNU GCC Compiler) ===|
E:\sleepy-discord\deps\include\asio\detail\impl\win_iocp_io_context.ipp|481|error: '::VerSetConditionMask' has not been declared|
E:\sleepy-discord\deps\include\asio\detail\impl\win_iocp_io_context.ipp|482|error: 'VER_MAJORVERSION' was not declared in this scope|
E:\sleepy-discord\deps\include\asio\detail\impl\win_iocp_io_context.ipp|482|error: 'VER_GREATER_EQUAL' was not declared in this scope|
E:\sleepy-discord\deps\include\asio\detail\impl\win_object_handle_service.ipp||In member function 'void asio::detail::win_object_handle_service::move_construct(asio::detail::win_object_handle_service::implementation_type&, asio::detail::win_object_handle_service::implementation_type&)':|
E:\sleepy-discord\deps\include\asio\detail\impl\win_object_handle_service.ipp|106|error: '::UnregisterWaitEx' has not been declared|
E:\sleepy-discord\deps\include\asio\detail\impl\win_object_handle_service.ipp||In member function 'void asio::detail::win_object_handle_service::move_assign(asio::detail::win_object_handle_service::implementation_type&, asio::detail::win_object_handle_service&, asio::detail::win_object_handle_service::implementation_type&)':|
E:\sleepy-discord\deps\include\asio\detail\impl\win_object_handle_service.ipp|158|error: '::UnregisterWaitEx' has not been declared|
E:\sleepy-discord\deps\include\asio\detail\impl\win_object_handle_service.ipp||In member function 'void asio::detail::win_object_handle_service::destroy(asio::detail::win_object_handle_service::implementation_type&)':|
E:\sleepy-discord\deps\include\asio\detail\impl\win_object_handle_service.ipp|201|error: '::UnregisterWaitEx' has not been declared|
E:\sleepy-discord\deps\include\asio\detail\impl\win_object_handle_service.ipp||In member function 'asio::error_code asio::detail::win_object_handle_service::close(asio::detail::win_object_handle_service::implementation_type&, asio::error_code&)':|
E:\sleepy-discord\deps\include\asio\detail\impl\win_object_handle_service.ipp|253|error: '::UnregisterWaitEx' has not been declared|
E:\sleepy-discord\deps\include\asio\detail\impl\win_object_handle_service.ipp||In member function 'asio::error_code asio::detail::win_object_handle_service::cancel(asio::detail::win_object_handle_service::implementation_type&, asio::error_code&)':|
E:\sleepy-discord\deps\include\asio\detail\impl\win_object_handle_service.ipp|305|error: '::UnregisterWaitEx' has not been declared|
E:\sleepy-discord\deps\include\asio\detail\impl\win_object_handle_service.ipp||In member function 'void asio::detail::win_object_handle_service::register_wait_callback(asio::detail::win_object_handle_service::implementation_type&, asio::detail::win_mutex::scoped_lock&)':|
E:\sleepy-discord\deps\include\asio\detail\impl\win_object_handle_service.ipp|379|error: 'RegisterWaitForSingleObject' was not declared in this scope|
E:\sleepy-discord\deps\include\asio\detail\impl\win_object_handle_service.ipp|405|error: '::UnregisterWaitEx' has not been declared|
E:\sleepy-discord\deps\include\asio\detail\impl\win_object_handle_service.ipp|421|error: 'RegisterWaitForSingleObject' was not declared in this scope|
E:\sleepy-discord\deps\include\websocketpp\transport\asio\endpoint.hpp||In member function 'void websocketpp::transport::asio::endpoint<config>::handle_accept(websocketpp::transport::accept_handler, const error_code&)':|
E:\sleepy-discord\deps\include\websocketpp\transport\asio\endpoint.hpp|839|error: 'operation_canceled' is not a member of 'std::errc'|
||=== Build failed: 12 error(s), 0 warning(s) (0 minute(s), 5 second(s)) ===|
yourWaifu commented 6 years ago

Now I don't know how to use Code::Blocks so you'll need to look up some of these directions but I think you want to define the nt version of windows you are using with the preprocessor definitions _WIN32_WINNT and WINVER. For example for windows 7, -D_WIN32_WINNT=0x0601 -DWINVER=0x0601. More info about this can be found here https://docs.microsoft.com/en-us/windows/desktop/WinProg/using-the-windows-headers.

And maybe link the library wsock32 just in case. For example, -lwsock32. It's a windows library that you can found more info about here https://docs.microsoft.com/en-us/windows/desktop/winsock/windows-sockets-start-page-2 and here https://docs.microsoft.com/en-us/windows/desktop/api/_winsock/.

jedenastka commented 6 years ago

Not fixed, but I left Code::Blocks for now, sooo... Closing.