problems installing ofNetwork for 0.04

Here are the steps I have been through…

  1. Copied ofThread into *C:\OpenFrameWorks\v0.04\addons\ofThread*

  2. Added ofThread .h and .cpp to project, and ofThread in c++ include folder in project properties.

  3. Copied ofNetwork to *C:\OpenFrameWorks\v0.04\addons\ofNetwork*

  4. Added ofNetwork, ofTCPClient, ofTCPManager, ofTCPServer, ofUDPManager

  5. Copied WS2_32.Lib to OpenFrameWorks\v0.04\libs

  6. Added WS2_32.Lib in project properties linker and added the libs path folder.

When I go to build, I get 612 errors, looking a bit like this…

1>Compiling…
1>ofUDPManager.cpp
1>C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winsock2.h(112) : error C2011: ‘fd_set’ : ‘struct’ type redefinition
1> C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winsock.h(54) : see declaration of ‘fd_set’
1>C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winsock2.h(147) : warning C4005: ‘FD_SET’ : macro redefinition
1> C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winsock.h(88) : see previous definition of ‘FD_SET’

Any ideas? Thanks

yeah
welcome to winsock hell !!

I don’t know how to help you w/ 0.04 but would ask that you either hold tight for 0.05 - or download the 0.05 version (temporary work in progress) listed in the forums (for devcpp) where you can see how we did the includes in the “all addons” example. This was a big problem that’s fixed in 0.05 I think by using WINDOWS_MEAN_AND_LEAN in ofConstants and likely a couple other changes. 0.05 is coming - (and taking so long just for the reasons that you are discovering on your own!)

hope that helps
zach

oh yeah - I remember this one.

I think you have to make sure you include “winsock2.h” before including windows.h - you can do that in ofConstants.h

If you don’t winsock gets included first and then you get those errors.

hope the works!
theo

yeah theo is right - it’s a winsock problem w/ multiple definitions. windows includes winsock, but we want to use winsock2.h… therefore, trouble if you include the addons after including windows.

for 0.05 since it pretty much impossible to control include order of the addons (since h file includes are recursive) I had to do:

  
  
	#define WIN32_LEAN_AND_MEAN  
	#include <windows.h>  
  

this drops windows winsock include (helpful for the 600 errors you have) but it leads to other issues as I recall (it was an afternoon of hitting my head against the wall), so I think that you can try it and see what errors you have.

I’d poke around the ofConstants.h on the of.cc/files listed in the forum (snapshots of 0.05) – I think I may have had to change some other stuff, but can’t remember off the top of my head.

hope that helps!
zach