C++ Visual Studio 2013:致命错误 C1083:无法打开包含文件:'winsock2.h':没有这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19736036/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio 2013: fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
提问by moodboom
I migrated some "native" c++ projects from Visual Studio 2010 on Windows 7 to Visual Studio 2013 on Windows 8.1. Rebuilding gave me this error. I realized I did not have the Windows SDK installed, so I installed that next, but I'm still getting the error. Anyone else get this on otherwise-clean VS project migrations?
我将一些“本机”c++ 项目从 Windows 7 上的 Visual Studio 2010 迁移到 Windows 8.1 上的 Visual Studio 2013。重建给了我这个错误。我意识到我没有安装 Windows SDK,所以我接下来安装了它,但我仍然收到错误消息。还有其他人在其他干净的 VS 项目迁移中得到这个吗?
采纳答案by moodboom
I searched under the SDK folder for the missing file and found it. Because the SDK was installed after I migrated the projects, the paths were not included in my projects. I was able to fix everything by adding to my include and lib paths.
我在 SDK 文件夹下搜索丢失的文件并找到它。因为我迁移项目后安装了SDK,所以我的项目中没有包含路径。我能够通过添加到我的包含和库路径来修复所有内容。
I added the following folders to my include paths:
我将以下文件夹添加到我的包含路径中:
$(WindowsSdkDir)include\um
$(WindowsSdkDir)include\shared
$(WindowsSdkDir)include\um
$(WindowsSdkDir)include\shared
My full include path for both Debug and Release now looks like this:
我的 Debug 和 Release 的完整包含路径现在如下所示:
$(WindowsSdkDir)include;$(WindowsSdkDir)include\um;$(WindowsSdkDir)include\shared;$(FrameworkSDKDir)\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;
$(WindowsSdkDir)include;$(WindowsSdkDir)include\um;$(WindowsSdkDir)include\shared;$(FrameworkSDKDir)\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;
I added the following folder to my lib paths (note that is specific to a 32-bit build! see x64 for 64-bit, and arm for arm builds...):
我将以下文件夹添加到我的 lib 路径中(请注意,这是特定于 32 位构建的!请参阅 x64 用于 64 位,而 arm 用于 arm 构建......):
$(WindowsSdkDir)lib\winv6.3\um\x86
$(WindowsSdkDir)lib\winv6.3\um\x86
My full lib path looks like this:
我的完整 lib 路径如下所示:
$(WindowsSdkDir)lib;$(WindowsSdkDir)lib\winv6.3\um\x86;$(FrameworkSDKDir)\lib;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib
$(WindowsSdkDir)lib;$(WindowsSdkDir)lib\winv6.3\um\x86;$(FrameworkSDKDir)\lib;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib
Note that if you have a copy of the original project file, you can also fix the problem by re-migrating it again after the Windows SDK is installed.
请注意,如果您有原始项目文件的副本,您也可以在安装 Windows SDK 后通过重新迁移来解决问题。
回答by leaf
include path: $(VC_IncludePath);$(WindowsSDK_IncludePath);
包括路径: $(VC_IncludePath);$(WindowsSDK_IncludePath);
lib paths:$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);
库路径:$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);