1

I'm trying to build my project (wpilib) on windows, coming from linux where it works fine. I installed mingw, but that didn't seem to have all the threading stuff I'm using, so I deleted it and installed mingw-x64. That got me further, but now I'm stuck here.

In file included from C:/Program Files/mingw-w64/x86_64-5.1.0-posix-seh-rt_v4-rev0/mingw64/x86_64-w64-mingw32/include/winsock2.h:55:0,
                 from C:\Users\peter\gz-ws\boost_1_56_0/boost/asio/detail/socket_types.hpp:38,
                 from C:\Users\peter\gz-ws\boost_1_56_0/boost/asio/detail/win_tss_ptr.hpp:23,
                 from C:\Users\peter\gz-ws\boost_1_56_0/boost/asio/detail/tss_ptr.hpp:25,
                 from C:\Users\peter\gz-ws\boost_1_56_0/boost/asio/detail/call_stack.hpp:20,
                 from C:\Users\peter\gz-ws\boost_1_56_0/boost/asio/impl/handler_alloc_hook.ipp:19,
                 from C:\Users\peter\gz-ws\boost_1_56_0/boost/asio/handler_alloc_hook.hpp:80,
                 from C:\Users\peter\gz-ws\boost_1_56_0/boost/asio/detail/handler_alloc_helpers.hpp:21,
                 from C:\Users\peter\gz-ws\boost_1_56_0/boost/asio/detail/bind_handler.hpp:19,
                 from C:\Users\peter\gz-ws\boost_1_56_0/boost/asio/detail/wrapped_handler.hpp:18,
                 from C:\Users\peter\gz-ws\boost_1_56_0/boost/asio/io_service.hpp:24,
                 from C:\Users\peter\gz-ws\boost_1_56_0/boost/asio/basic_io_object.hpp:19,
                 from C:\Users\peter\gz-ws\boost_1_56_0/boost/asio/basic_socket.hpp:20,
                 from C:\Users\peter\gz-ws\boost_1_56_0/boost/asio/basic_datagram_socket.hpp:20,
                 from C:\Users\peter\gz-ws\boost_1_56_0/boost/asio.hpp:21,
                 from C:\Users\peter\gz-ws\gazebo\build\install\Debug\include\gazebo-6.0/gazebo/transport/Connection.hh:23,
                 from C:\Users\peter\gz-ws\gazebo\build\install\Debug\include\gazebo-6.0/gazebo/transport/transport.hh:3,
                 from C:\Users\peter\wpilib\cpp\current\sim\include/DriverStation.h:9,
                 from C:\Users\peter\wpilib\cpp\current\sim\include/RobotBase.h:9,
                 from C:\Users\peter\wpilib\cpp\current\sim\include/WPILib.h:35,
                 from ..\src\OI.h:11,
                 from ..\src\OI.cpp:8: C:/Program Files/mingw-w64/x86_64-5.1.0-posix-seh-rt_v4-rev0/mingw64/x86_64-w64-mingw32/include/psdk_inc/_socket_types.h:11:9: error: 'UINT_PTR' does not name a type  typedef UINT_PTR SOCKET;
Gyrocode.com
  • 57,606
  • 14
  • 150
  • 185
Peter Mitrano
  • 2,132
  • 28
  • 31
  • In my `mingw` socket declared as `typedef UINT_PTR SOCKET;`, and `UINT_PTR` declared as `typedef unsigned int UINT_PTR,*PUINT_PTR;` in header `basetsd.h`. Try to include `basetsd.h` before `boost::asio` headers. – gomons Jun 18 '15 at 22:27
  • also add `ws2_32.lib` to your project – gomons Jun 18 '15 at 22:29
  • I tried adding `basetd.h` to no avail. If things go wront at linking time I'll try the second suggestion. – Peter Mitrano Jun 18 '15 at 22:47

1 Answers1

1

For some reason, adding the following to all my .cpp files seems to have fixed that particular problem. I've noticed that everyone seems to be putting this at the top, but I don't see the connection between this and UINT_PTR, which is defined in basetsd.h

#ifdef _WIN32
  // Ensure that Winsock2.h is included before Windows.h
  #include <Winsock2.h>
#endif

If anyone figure out why this fixes it, I'd love to know

Peter Mitrano
  • 2,132
  • 28
  • 31
  • `windows.h` includes `winsock.h`, `winsock2.h` disables `winsock.h` when included. There is a macro, that do the same thing, but I can't find it... – gomons Jun 18 '15 at 23:11
  • 1
    I found, `WIN32_LEAN_AND_MEAN` excludes APIs such as Cryptography, DDE, RPC, Shell, and Windows Sockets. So you can define `WIN32_LEAN_AND_MEAN` before `windows.h` and include `winsock2.h` after `windows.h` – gomons Jun 18 '15 at 23:13
  • Yes, I know that, but how does winsock2 have anything to do with this? Does it somehow effect basetsd.h? BTW I think you're looking for win32-lean-and-mean – Peter Mitrano Jun 18 '15 at 23:15
  • I see...I suppose since winsock2 us already included by boost and I'm not including either that or windows.h I'll use the macro – Peter Mitrano Jun 18 '15 at 23:16
  • Actually, when I use asio, I do not need include `winsock2.h` or `windows.h`. I use `mingw` that ships with Qt 5.4. Boost version 1.57. – gomons Jun 18 '15 at 23:22
  • hm... -DWIN32_LEAN_AND_MEAN doesn't do it. Could be something else including winsock.h I suppose. – Peter Mitrano Jun 18 '15 at 23:23
  • I'm not including either. or at least, I didn't until it started complaining. Now I have winsock2 included. It's probably boost or gazebo that's including things wrong... – Peter Mitrano Jun 18 '15 at 23:25
  • I [asked the same question earlier](http://stackoverflow.com/questions/29069904/why-does-mingw-w64-require-winsock2-to-be-manually-included) but didn't really get a clear answer. – M.M Jun 19 '15 at 00:16
  • Ya know, I wish I had one for you. My attitude right now is along the lines of screw windows let it burn in hell... – Peter Mitrano Jun 19 '15 at 00:18