Resolving errors when building cpp-httplib on Windows with Cmake

I was building on the cpp-httplib on windows with Cmake and it was giving me errors like

undefined reference to `__imp_WSASocketW’
undefined reference to `__imp_socket’
undefined reference to `__imp_setsockopt’
undefined reference to `__imp_freeaddrinfo’

this means you need to link your program with winsocket library
you can do this by adding this to your Cmake file

CMake
if(WIN32)

  target_link_libraries(${PROJECT_NAME}  wsock32 ws2_32)

endif()




Leave a Reply

Your email address will not be published. Required fields are marked *