Sai Wai Maung
Sai Wai Maung

Reputation: 1617

error C1083: cannot open include file: 'winsock2.h': No such file or directory

Visual Studio 2013 returns this error when I tried to build a Snare (http://www.intersectalliance.com/projects/BackLogNT/) project.

I installed the Windows SDK and I realized that I am supposed to include the SDK path into my project. Could anyone explain how to include the SDK path into a Visual Studio project?

Upvotes: 8

Views: 26538

Answers (5)

Abdel Aleem
Abdel Aleem

Reputation: 747

If you are encountering the same problem in Visual Studio 2019, the problem might be that you started off with a completely blank project. It literally states that there are no starting files. So instead I created a new project based on any other than "Empty Project". Now I could find winsock-files in external dependencies.

It may sound like a lazy workaround, but it will save you from the startup headache of having to tamper with include paths.

Upvotes: 0

Vahag Chakhoyan
Vahag Chakhoyan

Reputation: 779

I just downloaded and installed windows SDK 8.1 for my windows 7. VS2013 looks for winsock2.h header in C:\Program Files (x86)\Windows Kits\8.1 folder. This approach works for me.

Upvotes: 0

Igor Slepchenkov
Igor Slepchenkov

Reputation: 81

I think answer of Ruud van Gaal is more correct. What I did: - install Windows SDK for Windows XP (7.1) from here http://www.microsoft.com/en-us/download/details.aspx?id=8279

  • open the Project properties - Goto Configuration Properties -> General - Set the Platform Toolset to "Visual Studio 2013 - Windows XP (v120_xp)"

  • after this Include/Libraries paths were changed to correct folders $(VC_IncludePath);$(WindowsSdk_71A_IncludePath); $(VC_LibraryPath_x86);$(WindowsSdk_71A_LibraryPath_x86);

So I did NOT change them manually. Only targeting correct tool set and everything started to work.

Upvotes: 5

Ruud van Gaal
Ruud van Gaal

Reputation: 150

The answer by user2644318 is quite hardcoded. An alternative is to try this: - Open the Project properties - Goto Configuration Properties -> General - Set the Platform Toolset to v120_xp (Visual Studio 2013 - Windows XP) - Recompile

Funnily enough I can mix toolsets for libraries; they link fine. Ofcourse, this only gets you XP interface capabilities.

Upvotes: 6

Sai Wai Maung
Sai Wai Maung

Reputation: 1617

In Visual Studio 2013, under Solution Explorer, right click on the project -> Properties -> Configuration Properties -> VC++ Directories, then include (WindowsSDK_IncludePath_um); in Include and Library Directories. I was able to solve this issue with this approach.

Upvotes: 3

Related Questions