Skip to content

Compiling poco-1.5.2 for Cygwin #341

@drstacey

Description

@drstacey

Thank you for all your hard work on poco. Here are a few patches that I made to poco-1.5.2 to get it compiling on Cygwin.

  1. The Datagram Socket Test needs to check for POCO_NET_HAS_INTERFACE. This fails to compile in its present state, because the Cygwin build of Net doesn't have the NetworkInterface class:
--- origsrc/poco-1.5.2-all/Net/testsuite/src/DatagramSocketTest.cpp 2013-09-18 19:13:09.000000000 +0100
+++ src/poco-1.5.2-all/Net/testsuite/src/DatagramSocketTest.cpp 2013-11-17 19:39:14.223899700 +0000
@@ -46,7 +46,9 @@ using Poco::Net::Socket;
 using Poco::Net::DatagramSocket;
 using Poco::Net::SocketAddress;
 using Poco::Net::IPAddress;
+#ifdef POCO_NET_HAS_INTERFACE
 using Poco::Net::NetworkInterface;
+#endif // POCO_NET_HAS_INTERFACE
 using Poco::Timespan;
 using Poco::Stopwatch;
 using Poco::TimeoutException;
@@ -101,7 +103,7 @@ void DatagramSocketTest::testBroadcast()
    UDPEchoServer echoServer;
    DatagramSocket ss(IPAddress::IPv4);

-#if (POCO_OS != POCO_OS_FREE_BSD)
+#ifndef POCO_NET_HAS_INTERFACE
    SocketAddress sa("255.255.255.255", echoServer.port());
 #else
    NetworkInterface ni = NetworkInterface::forName("em0");
  1. When compiling Data/ODBC, the Makefile assumes that if 'libodbc.a' is present, then so is 'libodbcinst.a'. In Cygwin, this isn't the case: Cygwin provides 'libodbc.a' but not 'libodbcinst.a'. This patch checks for the existence of both:
--- origsrc/poco-1.5.1-all/Data/ODBC/ODBC.make  2013-01-12 08:28:43.000000000 +0000
+++ src/poco-1.5.1-all/Data/ODBC/ODBC.make  2013-11-17 16:50:33.152988200 +0000
@@ -22,6 +22,8 @@ endif

 ifeq ($(LINKMODE),STATIC)
 LIBLINKEXT = .a
+else ifeq ($(POCO_CONFIG),CYGWIN)
+LIBLINKEXT = .dll.a
 else
 LIBLINKEXT = $(SHAREDLIBLINKEXT)
 endif
@@ -38,20 +40,13 @@ ifeq ($(POCO_CONFIG),MinGW)
 CXXFLAGS += -DODBCVER=0x0300 -DNOMINMAX

 ##
-## Cygwin
-##
-else ifeq ($(POCO_CONFIG),CYGWIN)
-# -DODBCVER=0x0300: SQLHandle declaration issue
-# -DNOMINMAX      : MIN/MAX macros defined in windows conflict with libstdc++
-CXXFLAGS += -DODBCVER=0x0300 -DNOMINMAX
-# CYGWIN platform has its own ODBC library in /lib/w32api 
-SYSLIBS += -L/lib/w32api -lodbc32 -lodbccp32
-
-##
 ## unixODBC
 ##
 else ifeq (0, $(shell test -e $(POCO_ODBC_LIB)/libodbc$(LIBLINKEXT); echo $$?))
-SYSLIBS += -lodbc -lodbcinst
+SYSLIBS += -lodbc
+ifeq (0, $(shell test -e $(POCO_ODBC_LIB)/libodbcinst$(LIBLINKEXT); echo $$?))
+SYSLIBS += -lodbcinst
+endif
 COMMONFLAGS += -DPOCO_UNIXODBC

 ##
  1. In build/rules/lib, I'd appreciate it if you could remove the Cygwin-specific code. With this gone, we build versioned libraries as per the Linux builds:
--- origsrc/poco-1.4.6p1-all/build/rules/lib    2013-03-06 19:45:52.000000000 +0000
+++ src/poco-1.4.6p1-all/build/rules/lib    2013-11-16 22:47:53.654613400 +0000
@@ -9,15 +9,11 @@
 #
 # Target names
 #
-ifeq ($(OSNAME),CYGWIN)
-SHL_EXT = $(SHAREDLIBLINKEXT)
-else
 ifdef target_version
 SHL_EXT = $(SHAREDLIBEXT)
 else
 SHL_EXT = $(SHAREDLIBLINKEXT)
 endif
-endif

 LIB_RELEASE_STATIC      = $(LIBPATH)/$(LIBPREFIX)$(target)$(OSARCH_POSTFIX).a
 LIB_DEBUG_STATIC        = $(LIBPATH)/$(LIBPREFIX)$(target)d$(OSARCH_POSTFIX).a

Poco is maintained (by myself) as part of the Cygwin distribution, and this enables programmers to make use of the Poco libraries from within the Cygwin environment. These are the changes that I would make if I was to package poco-1.5.2 for Cygwin. Obviously, you have to support a great number of platforms, and I won't be in the slightest offended if you choose not to take any (or all) of the above.

Thank you once again for your hard work on Poco. Please let me know if I can be of any further help in supporting Poco in Cygwin.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions