Visual Studio #include
i don't have too much experience of using MS Visual Studio, therefore i need some help. i am trying to write a program using WinSock in Visual C++, so could someone tell be what i need to do to include the "winsock.h" header file, in MS Visual Studio. Beyond the following.
i've tried a number of solutions that i have found on the net, but non of them have completely worked. therefore could anyone help me?
thanks in advance,
That is actually all you need to do. If that's not working, then you have problems somewhere else. What problems are you having with it, exactly?
when i try to use WSAStartup(), then i get a build error. that says:
error LNK2019: unresolved external symbol _WSAStartup@8 referenced in function _main
which is why i think that the "winsock.h" library has not been included in the build. what do you think?
I haven't opened Visual Studio in years and I never used it for anything but Visual Basic, but as I recall there was a setting where you had to import a whole package that contained each library that you intend to reference. It's been too many years for me to tell you where to look and I have no idea how much the program has changed in that time.
I had to do such an import myself just to reference the scripting.filesystem object.
that's what i was thinking, that i may have to import the header file into my project.
but, im not sure how to do that. all the attempts that i have made have been unsuccessful ;-(.
although, i could easily be mistaken! anyone, that has any ideas how i could resolve this problem, please let me know.
thanks for your help guys, but i've worked out the answer to my own question! what i needed to do was, on the menus, go to:
project -> properties -> "configuration properties" -> linker -> input -> "additional dependancies"
and add "WS2_32.lib".
I'm glad you found it, I was about to tell you that the solution is not coding, but rather part of the menu interface. Anyway you solved it. Congrats!
It's actually a linker error. By adding the additional dependencies you're telling the linker to link the ws2_32.lib to your executable making it's functions available.
Don't know if this'll help you at all, but generally if the problem was that VS couldn't find the header file you would get an error along the lines of:
"Warning C4013: 'my_func' undefined; assuming extern, returning int"
Another way that you can get an idea of whether the issue is a compiler or a linker problem is by looking at the error codes. Compiler problems start with Cxxxx whereas linker problems start with LNKxxxx.
A good way to get help on these problems is to search by that error code.