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