Question:
I can't compile my C++ program?
anonymous
2007-07-24 12:11:50 UTC
This is just ridiculous. I'm trying to learn how to program sockets. So I include winsock2.h. I then right-click on my project (I'm using VC++ 2005), and I go to 'Properties'. I go to 'Linker' > 'Input' > 'Additional Dependencies' and then I add ws2_32.lib. Then I compile the program. It gives me an error, saying that it cannot open winsock2.h, because, apparently, it doesn't exist. WHAT THE HELL? I am running Windows Vista, so everything should be up to date. Please tell me what the hell I'm doing wrong. I have tried this with Dev-C++ also, and it doesn't work.
Five answers:
Tarindel
2007-07-24 12:32:45 UTC
Check out:

http://www.learncpp.com/cpp-tutorial/a2-using-libraries-with-visual-studio-2005-express/



Basically, you not only have to include the .lib in the linker additional dependencies, you also have to include the source path in the include files list.
David 19
2007-07-24 19:18:49 UTC
In the source program you will need to #include the .h file. You will also need to define the directory where it is located if it's outside your defined directory for header files. I'm not familiar with VC++ so there might be a different way to do it in that IDE.
Pfo
2007-07-24 19:16:23 UTC
Are you using "" or <> when including winsock2.h? Because <> is supposed to be for system include files in VC++ (I think Dev C++ too). Also, just to be sure, locate the file on your hard drive and make sure it exists.
Darrell D
2007-07-24 19:15:16 UTC
1. Find the directory where winsock2.h exists

2. Include that directory in your C++ build properties



Alternatively, actually add the winsock2.h file to your project manually.
anonymous
2007-07-24 19:22:50 UTC
I guess that would make it an F-- program wouldn't it? Har de har har...


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...