To fix the compilation errors, the Windows library ws2_32.lib needs to be linked to the final executable. This can be done in the following steps:
- Add the library ws2_32 to the CMakeLists.txt file, as shown below.
- Run CMake to build the Visual Studio project files.
C:\> cmake -G"Visual Studio 15 2017 Win64" ..
The project files are generated. - Open up the solution project in Visual Studio. Then build the solution.
The project is successfully built and the executable is generated.