Thursday, July 30, 2009

I can't compile my C++ program?

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' %26gt; 'Input' %26gt; '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.

I can't compile my C++ program?
Check out:


http://www.learncpp.com/cpp-tutorial/a2-...





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.
Reply:Are you using "" or %26lt;%26gt; when including winsock2.h? Because %26lt;%26gt; 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.
Reply:I guess that would make it an F-- program wouldn't it? Har de har har...
Reply: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.
Reply: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.

flamingo plant

No comments:

Post a Comment