cpp-redis / cpp_redis

C++11 Lightweight Redis client: async, thread-safe, no dependency, pipelining, multi-platform
MIT License
713 stars 198 forks source link

fail Socket() #44

Closed StiviiK closed 5 years ago

StiviiK commented 5 years ago

Hi there, i've created a minimal c++17 project, to test the library on windows, but when i run the code from below i get the error fail Socket().

#include <iostream>
#include "cpp_redis/cpp_redis"

int main(int argc, char* argv[])
{
    try {
        cpp_redis::client client;
        client.connect();
    } catch(std::exception& e)
    {
        std::cout << e.what() << std::endl;
    }

    std::cin.get();
    return 0;
}

Project was generated using the following premake5 file:

project "test"
    language "C++"
    cppdialect "C++17"
    kind "ConsoleApp"

    libdirs { "lib" }

    vpaths {
        ["Headers/*"] = "**.h",
        ["Sources/*"] = "**.cpp",
        ["Test files"] = "**.json",
        ["*"] = "premake5.lua"
    }

    files {
        "premake5.lua",
        "**.cpp",
        "**.h",
    }

    filter { "system:windows", "platforms:x86" }
        links { "tacopie.lib" }
        links { "cpp_redis.lib" }

    filter { "system:windows", "platforms:x64" }
        links { "tacopie_64.lib" }
        links { "cpp_redis_64.lib" }

    filter "system:linux"
meaningful commented 5 years ago

how do you deal with this problem?

StiviiK commented 5 years ago

Oh, i forgot that. You have to initialize the windows sockets library before: https://docs.microsoft.com/en-us/windows/win32/winsock/initializing-winsock