Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7682053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:28:44+00:00 2026-05-31T18:28:44+00:00

I have had nothing but trouble with Winsock since I started using it. I

  • 0

I have had nothing but trouble with Winsock since I started using it. I cannot seem to initialize Winsock to save my life. I’m not asking for anyone to write the whole program ( As I know how annoying that is ) I just need help with Winsock. I have tried several compilers and always get weird errors.

1>Compiling...
1>main.cpp
1>Linking...
1>main.obj : error LNK2019: unresolved external symbol __imp__WSACleanup@0 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function _main
1>C:\Users\Rory\ProjectX\ProjectX\Debug\ProjectX.exe : fatal error LNK1120: 2 unresolved externals
1>Build log was saved at "file://c:\Users\Rory\ProjectX\ProjectX\ProjectX\Debug\BuildLog.htm"
1>ProjectX - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Here is my code:

#include <cstdlib>
#include <iostream>
#include <string.h>
#include <winsock2.h>

int iReqWinsockVer = 2;

using namespace std;

int main()
{
    cout<<"Initializing Winsock 2...\n";

    // WINSOCK INITIALIZATION

WSADATA wsaData;

if (WSAStartup(MAKEWORD(iReqWinsockVer,0), &wsaData)==0) {
    // Check if major version is at least iReqWinsockVer
    if (LOBYTE(wsaData.wVersion) >= iReqWinsockVer) {
        // Network stuff here
    }
    else {
        // Required version not available
    }

    // Cleanup winsock
    if (WSACleanup()!=0) {
        // cleanup failed
        }
    }
else {
    //  startup failed
}
    // END WINSOCK INITIALIZATION

        system("PAUSE");
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:28:45+00:00Added an answer on May 31, 2026 at 6:28 pm

    Add ws2_32.lib as linker input.

    Project Properties->linker->input page

    On that page you will see Additional Dependencies.
    Put it in there – note that library names should be seperated with spaces
    Or you could add this line directly to your source file:

    #pragma comment(lib, "ws2_32.lib") 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello all at StackOverflow.. Reasonably new to this site, but I have had nothing
I have just upgraded to SVN 1.7.1 and I have had nothing but problems
We have had SharePoint where I work for a little while now, but we've
We have had issues with Mootools not being very backward compatible specifically in the
Any one else had trouble with contracts. I have the following: public void doSomeThing(Stack
I have browsed StackOverflow and found a couple questions/answers that are close but not
I have been trying to fix this for a while but I have had
Have had to write my first proper multithreaded coded recently, and realised just how
I have had to do this several times, usually when trying to find in
I have had a bug recently that only manifested itself when the library was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.