Jump to content
  • Advertisement
Sign in to follow this  
Drezard

Visual C++ 2005 and Winsock HELP!

This topic is 3615 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm currently trying to link the Winsock 2 library to a Visual C++ 2005 project. I'll try and give as much information as I can... I need instructions or a nice tutorial somewhere on how to link the Winsock 2 library to a V C++ 2005 project. I have searched google for almost 2 hours now trying to find anything about it but ive found about 40 different ways of doing it and none of them work for me! Can anyone give me a quick step by step guide? or link me in the right direction? I'm using a brand new 'full' install of Visual Studio 2005 Professional, Windows XP Prof and thats about all I can give you. Please help! I can give any other information needed! Thanks, Daniel

Share this post


Link to post
Share on other sites
Advertisement
Alt+F7 (Project properties) -> Configuration Properties -> Linker -> Input. In "Additional Dependencies", add "ws2_32.lib" (no quotes).

Or, add the following in one .cpp file:
#pragma comment(lib, "ws2_32.lib")

Share this post


Link to post
Share on other sites
Still giving me all the errors. Anyother ideas? Do i need to add winsock2.h to my project file? or?

Daniel

Share this post


Link to post
Share on other sites
Ive done that... Ive added it, it doesn't work still. Do I need to add winsock2.h or anything else in my project directory? or anything? I have done anything except, new project > Console app > empty. Added in some simple winsock code. Added in that link in the linker and hit compile.

Other ideas?

Share this post


Link to post
Share on other sites
winsock2.h and windows.h use some nasty macro trickery so the older winsock.h gets not included. Both collide.

You have to make sure that winsock2.h gets included before(!) windows.h. Note that may also occur indirectly.

Share this post


Link to post
Share on other sites
The solution to include-order problems with winsock is to create your own header that includes winsock, then includes windows, and always include that rather than either of the two.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!