CLION: undefined reference to __imp_socket
Clion 运行socket程序出现如此报错, 解决方法, 在CMakeList中加入
if(MINGW)
target_link_libraries(yourTargetName ws2_32)
endif()
当在CLION环境下运行socket程序遇到undefinedreferenceto__imp_socket错误时,可以在CMakeLists中添加条件判断,针对MINGW环境链接ws2_32库,如:target_link_libraries(yourTargetNamews2_32)。
if(MINGW)
target_link_libraries(yourTargetName ws2_32)
endif()
3202
2084

被折叠的 条评论
为什么被折叠?