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. Winsock2.h and "unresolved external error"

Winsock2.h and "unresolved external error"

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 4 Posters 5 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.
  • M Offline
    M Offline
    Mutty
    wrote on last edited by
    #1

    I am trying to do this: char szHostName[MAX_PATH]; gethostname(szHostName, MAX_PATH); I have included winsock2.h yet am getting: error LNK2019: unresolved external symbol __imp__gethostname@8 Anybody know what I am missing? VS2002 thanks, -mutty

    J D 2 Replies Last reply
    0
    • M Mutty

      I am trying to do this: char szHostName[MAX_PATH]; gethostname(szHostName, MAX_PATH); I have included winsock2.h yet am getting: error LNK2019: unresolved external symbol __imp__gethostname@8 Anybody know what I am missing? VS2002 thanks, -mutty

      J Offline
      J Offline
      James R Twine
      wrote on last edited by
      #2

      Sounds like you are not linking with the Winsock2 library (Ws2_32.lib).    Peace! -=- James


      If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
      Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
      DeleteFXPFiles & CheckFavorites (Please rate this post!)

      M 1 Reply Last reply
      0
      • M Mutty

        I am trying to do this: char szHostName[MAX_PATH]; gethostname(szHostName, MAX_PATH); I have included winsock2.h yet am getting: error LNK2019: unresolved external symbol __imp__gethostname@8 Anybody know what I am missing? VS2002 thanks, -mutty

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

        Mutty wrote:

        I have included winsock2.h yet am getting: error LNK2019: unresolved external symbol __imp__gethostname@8

        Linker errors and header files (usually) have nothing to do with each other. Had it been a header-related issue, you would have most likely seen a compiler error.


        "The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli

        1 Reply Last reply
        0
        • J James R Twine

          Sounds like you are not linking with the Winsock2 library (Ws2_32.lib).    Peace! -=- James


          If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
          Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
          DeleteFXPFiles & CheckFavorites (Please rate this post!)

          M Offline
          M Offline
          Mutty
          wrote on last edited by
          #4

          thank you - how do I link WS2_32.lib? Stupid - never mind this. I was trying to open the property pages for the SOLUTION, not the Project. No wonder there was no linker folder! -mutty -- modified at 13:42 Tuesday 14th February, 2006

          T 1 Reply Last reply
          0
          • M Mutty

            thank you - how do I link WS2_32.lib? Stupid - never mind this. I was trying to open the property pages for the SOLUTION, not the Project. No wonder there was no linker folder! -mutty -- modified at 13:42 Tuesday 14th February, 2006

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            Mutty wrote:

            thank you - how do I link WS2_32.lib?

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

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV

            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