Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Winsock

Winsock

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++delphisysadmin
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jocblack
    wrote on last edited by
    #1

    Hi: I am building a client program in VC++ 6.0 using WINSOCK to connect to the server. I have a very small program that testing WINSOCK. My program contains include statement for WINSOCK2.h. Here is the code to initialize WINSOCK. WSADATA wsaData; int iResult; iResult = WSAStartup(0x0202, &wsaData); if (iResult != 0) { printf("WSAStartup failed: %d\n", iResult); } Errors: Linking... testwin1Dlg.obj : error LNK2001: unresolved external symbol __imp__WSAStartup@8 Debug/testwin1.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. testwin1.exe - 2 error(s), 0 warning(s) Additional Comment: I looked in WINSOCK.H and WINSOCK2.H and both has WSAStartup. In WINSOCK.H, it was PASCAL version. In WINSOCK2.H, it was either C or C++ version. Both version has the same signature (calling argurment). Can this be an issue? if yes, how can I eliminate the PASCAL version (WINSOCK.H)? Note that, I never include WINSOCK.H. Thanks Bill

    D M 2 Replies Last reply
    0
    • J jocblack

      Hi: I am building a client program in VC++ 6.0 using WINSOCK to connect to the server. I have a very small program that testing WINSOCK. My program contains include statement for WINSOCK2.h. Here is the code to initialize WINSOCK. WSADATA wsaData; int iResult; iResult = WSAStartup(0x0202, &wsaData); if (iResult != 0) { printf("WSAStartup failed: %d\n", iResult); } Errors: Linking... testwin1Dlg.obj : error LNK2001: unresolved external symbol __imp__WSAStartup@8 Debug/testwin1.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. testwin1.exe - 2 error(s), 0 warning(s) Additional Comment: I looked in WINSOCK.H and WINSOCK2.H and both has WSAStartup. In WINSOCK.H, it was PASCAL version. In WINSOCK2.H, it was either C or C++ version. Both version has the same signature (calling argurment). Can this be an issue? if yes, how can I eliminate the PASCAL version (WINSOCK.H)? Note that, I never include WINSOCK.H. Thanks Bill

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      jocblack wrote:

      testwin1Dlg.obj : error LNK2001: unresolved external symbol __imp__WSAStartup@8

      So are you linking with the correct library.


      "A good athlete is the result of a good and worthy opponent." - David Crow

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      1 Reply Last reply
      0
      • J jocblack

        Hi: I am building a client program in VC++ 6.0 using WINSOCK to connect to the server. I have a very small program that testing WINSOCK. My program contains include statement for WINSOCK2.h. Here is the code to initialize WINSOCK. WSADATA wsaData; int iResult; iResult = WSAStartup(0x0202, &wsaData); if (iResult != 0) { printf("WSAStartup failed: %d\n", iResult); } Errors: Linking... testwin1Dlg.obj : error LNK2001: unresolved external symbol __imp__WSAStartup@8 Debug/testwin1.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. testwin1.exe - 2 error(s), 0 warning(s) Additional Comment: I looked in WINSOCK.H and WINSOCK2.H and both has WSAStartup. In WINSOCK.H, it was PASCAL version. In WINSOCK2.H, it was either C or C++ version. Both version has the same signature (calling argurment). Can this be an issue? if yes, how can I eliminate the PASCAL version (WINSOCK.H)? Note that, I never include WINSOCK.H. Thanks Bill

        M Offline
        M Offline
        Michael Sadlon
        wrote on last edited by
        #3

        Under Additional Dependencies for your Linker, add "ws2_32.lib" I think it was. Anytime you use functions that aren't compiled from inside your solution/project you need to include the .h AND the .lib file. The only other way is to load the DLL at runtime, but I don't have experience with that. Good luck :)

        J 1 Reply Last reply
        0
        • M Michael Sadlon

          Under Additional Dependencies for your Linker, add "ws2_32.lib" I think it was. Anytime you use functions that aren't compiled from inside your solution/project you need to include the .h AND the .lib file. The only other way is to load the DLL at runtime, but I don't have experience with that. Good luck :)

          J Offline
          J Offline
          jocblack
          wrote on last edited by
          #4

          I was able to force the linker to use "ws2_32.lib" by adding the following line in my code. #pragma comment(lib, "ws2_32.lib") I found this in MSDN but it took a lot of search. Thanks

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups