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.
Code:
#include <winsock.h>
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,
- User0182
April 23rd, 2008, 10:48 PM
delstar
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?
April 23rd, 2008, 10:55 PM
user0182
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?
April 23rd, 2008, 11:58 PM
JPnyc
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.
April 24th, 2008, 12:37 AM
user0182
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.
April 24th, 2008, 07:26 PM
user0182
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:
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!
April 25th, 2008, 08:01 AM
SirDice
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.
April 25th, 2008, 01:28 PM
gothic_type
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:
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.