已经添加了
#pragma comment( lib, "version.lib" )
#pragma comment( lib, "netapi32.lib" )
在工程中引用ws2_32.lib庫了。用vc2005编译《Windows网络编程技术》附书源码nbclient.c出现如下错误
望大虾指教!!
------ 已启动全部重新生成: 项目: nbclient, 配置: Debug Win32 ------
正在删除项目“nbclient”(配置“Debug|Win32”)的中间文件和输出文件
正在编译...
nbclient.c
d:\vcsheji\nbclient\nbclient\nbclient.c(50) : warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\vs 2005\vc\include\string.h(157) : 参见“strncpy”的声明
d:\vcsheji\nbclient\nbclient\nbclient.c(53) : warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\vs 2005\vc\include\string.h(157) : 参见“strncpy”的声明
d:\vcsheji\nbclient\nbclient\nbclient.c(99) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\vs 2005\vc\include\string.h(74) : 参见“strcpy”的声明
d:\vcsheji\nbclient\nbclient\nbclient.c(155) : warning C4133: “函数”: 从“char [1024]”到“LPWSTR”的类型不兼容
d:\vcsheji\nbclient\nbclient\nbclient.c(155) : warning C4133: “函数”: 从“char [18]”到“LPCWSTR”的类型不兼容
d:\vcsheji\nbclient\nbclient\nbclient.c(158) : warning C4267: “函数”: 从“size_t”转换到“DWORD”,可能丢失数据
正在编译资源清单...
正在链接...
nbclient.obj : error LNK2019: 无法解析的外部符号 _DelName,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _Recv,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _Send,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _Hangup,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _Cancel,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _AddName,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _ResetAll,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _LanaEnum,该符号在函数 _main 中被引用MSVCRTD.lib(crtexew.obj) : error LNK2019: 无法解析的外部符号 _WinMain@16,该符号在函数 ___tmainCRTStartup 中被引用
D:\vcsheji\nbclient\Debug\nbclient.exe : fatal error LNK1120: 9 个无法解析的外部命令
生成日志保存在“file://d:\vcsheji\nbclient\nbclient\Debug\BuildLog.htm”
nbclient - 10 个错误,6 个警告
========== 全部重新生成: 0 已成功, 1 已失败, 0 已跳过 ==========
d:\vs 2005\vc\include\string.h(157) : 参见“strncpy”的声明
d:\vcsheji\nbclient\nbclient\nbclient.c(53) : warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\vs 2005\vc\include\string.h(157) : 参见“strncpy”的声明
d:\vcsheji\nbclient\nbclient\nbclient.c(99) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\vs 2005\vc\include\string.h(74) : 参见“strcpy”的声明
这几个警告是告诉你使用的函数是不安全的,可以改成提示中给出的函数,不改也没关系。d:\vcsheji\nbclient\nbclient\nbclient.c(155) : warning C4133: “函数”: 从“char [1024]”到“LPWSTR”的类型不兼容
d:\vcsheji\nbclient\nbclient\nbclient.c(155) : warning C4133: “函数”: 从“char [18]”到“LPCWSTR”的类型不兼容
这两个警告是因为2005默认使用Unicode字符集,应该使用WCHAR来定义字符并使用Unicode的字符串处理函数,你可以在项目属性中把字符集改成使用多字节字符集就没有这类问题了。d:\vcsheji\nbclient\nbclient\nbclient.c(158) : warning C4267: “函数”: 从“size_t”转换到“DWORD”,可能丢失数据
这个警告只要加上(DWORD)强制转换一下就没问题了,不改也没关系。nbclient.obj : error LNK2019: 无法解析的外部符号 _DelName,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _Recv,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _Send,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _Hangup,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _Cancel,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _AddName,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _ResetAll,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _LanaEnum,该符号在函数 _main 中被引用MSVCRTD.lib(crtexew.obj) : error
这些连接错误是因为没有包含相应的库文件或者没有把相应的c或cpp文件加到项目中而引起的,找出相应的文件加到项目里面就可以了,如果不知道需要什么文件,可以看看书上有没有说明。
D:\vcsheji\nbclient\Debug\nbclient.exe : fatal error LNK1120: 9 个无法解析的外部命令
你现在用的是Win32应用程序项目,应该创建一个控制台类型的项目。
------ 已启动生成: 项目: net, 配置: Debug Win32 ------
正在链接...
nbclient.obj : error LNK2019: 无法解析的外部符号 _DelName,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _Recv,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _Send,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _Hangup,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _Cancel,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _AddName,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _ResetAll,该符号在函数 _main 中被引用
nbclient.obj : error LNK2019: 无法解析的外部符号 _LanaEnum,该符号在函数 _main 中被引用
D:\vcsheji\net\Debug\net.exe : fatal error LNK1120: 8 个无法解析的外部命令
生成日志保存在“file://d:\vcsheji\net\net\Debug\BuildLog.htm”
net - 9 个错误,0 个警告
========== 生成: 0 已成功, 1 已失败, 0 最新, 0 已跳过 ==========