how to link winsock in cmake?

放肆的年华 提交于 2020-05-25 11:27:24

问题


I found only this strings

    find_library(WSOCK32_LIBRARY wsock32)
    find_library(WS2_32_LIBRARY ws2_32)

(i'm begginer in cmake) how to link winsock2 (winsock?) in cmake?


回答1:


Since these are both part of the Windows SDK, you shouldn't need to do a search for them. Assuming you have the SDK installed, you can just do something like:

add_executable(MyExe main.cpp)
if(WIN32)
  target_link_libraries(MyExe wsock32 ws2_32)
endif()


来源:https://stackoverflow.com/questions/15119639/how-to-link-winsock-in-cmake

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!