简体   繁体   English

无法在 visual studio 2022 上打开源文件

[英]Cannot open source file on visual studio 2022

#define _WINSOCK_DEPRECATED_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

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

#include <Winsock2.h>
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>

I have visual studio 2022 installed and I just downloaded the newest SDK. I am trying to use winsock (I am using parallels in m1 mac and running windows 10) and none of the libraries are working.我安装了 visual studio 2022,我刚刚下载了最新的 SDK。我正在尝试使用 winsock(我在 m1 mac 中使用 parallels 并运行 windows 10),但没有一个库在工作。 STDIO.H is pulling up "cannot open source file".. for all headers. STDIO.H 正在为所有标头拉起“无法打开源文件”。

Please check if the header file is included in the header file directory.请检查头文件是否包含在头文件目录中。 the C++ headers path are: C++ 头文件路径是:

1.C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include 1.C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include

2.C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt 2.C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt

The first contains standard C++ headers such as iostream .第一个包含标准 C++ 头文件,例如iostream The second contains legacy C headers such as stdio.h .第二个包含传统的 C 头文件,例如stdio.h

If you are going to use C++ to develop desktop applications, I recommend you to refer to my setup.如果您打算使用 C++ 开发桌面应用程序,我建议您参考我的设置。

在此处输入图像描述

Regarding the problem that the library cannot be used, I suggest you to read this document carefully, which explains how to use the dll.关于库无法使用的问题,建议大家仔细阅读这篇文档,里面解释了如何使用dll。 If this solution does not solve your problem, please leave a message.如果此解决方案不能解决您的问题,请留言。

stdio and stdlib are part of the C++ Standard Library headers, if you are getting the error E1696: 'cannot open source file , you might have to retarget the solution/project. stdiostdlib是 C++ 标准库头文件的一部分,如果您收到错误E1696: 'cannot open source file ,您可能需要重新定位解决方案/项目。 Do the following:请执行下列操作:

  1. Right-click the Solution in the Solution Explorer pane;右键单击解决方案资源管理器窗格中的解决方案;
  2. Retarget solution;重定向解决方案;
  3. Follow the steps/press OK.按照步骤操作/按 OK。

Hope it helps.希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM