在Visual C ++ Express中进行链接的帮助 [英] Help with linking in Visual C++ Express

查看:60
本文介绍了在Visual C ++ Express中进行链接的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是VC ++的新手,并且想知道如何在VC ++中链接"wsock32.lib".我正在尝试编写一个简单的c ++服务器应用程序,这些是我收到的错误消息.那么,我该如何在VC ++中进行链接呢?wsock32也是我需要的正确库吗?

I'm new to VC++ and would like to know know how to link "wsock32.lib" within VC++. I'm trying to write a simple c++ server app and these are the error messages I'm getting. So how do I go about linking something in VC++?. Also is wsock32 the correct lib that I need?

1>------ Build started: Project: bla, Configuration: Debug Win32 ------
1>bla.obj : error LNK2019: unresolved external symbol _closesocket@4 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _send@16 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _recv@16 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _accept@12 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _listen@8 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _bind@12 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _socket@12 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _htons@4 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _WSAStartup@8 referenced in function _main
1>C:\Users\-r.s-\Desktop\bla\Debug\bla.exe : fatal error LNK1120: 9 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

推荐答案

您应与"ws2_32.lib"库链接.在项目设置中或通过pragma指令在源代码中指定它:

You should link with "ws2_32.lib" library. Specify it in project settings or in source code via pragma directive:

#pragma comment(lib, "ws2_32.lib")

添加:AFAIK Visual C ++ Express不包含Platform SDK,因此,如果在计算机上找不到库,则应下载并安装.

Addition: AFAIK Visual C++ Express does not includes Platform SDK, so if you can't find library on your computer you should download and install Platform SDK and add necessary folders in Visual Studio "VC++ Directories" property page.

这篇关于在Visual C ++ Express中进行链接的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆