diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## Version 3.1.2.9
+
+* Resolving the runtime linker problem on Windows.
+  [#552](https://github.com/haskell/network/issues/552)
+
 ## Version 3.1.2.8
 
 * Ignoring error from shutdown in gracefulClose
diff --git a/Network/Socket/Options.hsc b/Network/Socket/Options.hsc
--- a/Network/Socket/Options.hsc
+++ b/Network/Socket/Options.hsc
@@ -353,8 +353,7 @@
   | isSupportedSocketOption s = action >> return ()
   | otherwise                 = return ()
 
--- | Set a socket option that expects an Int value.
--- There is currently no API to set e.g. the timeval socket options
+-- | Set a socket option that expects an 'Int' value.
 setSocketOption :: Socket
                 -> SocketOption -- Option Name
                 -> Int          -- Option Value
@@ -379,8 +378,7 @@
           throwSocketErrorIfMinus1_ "Network.Socket.setSockOpt" $
           c_setsockopt fd level opt ptr sz
 
--- | Get a socket option that gives an Int value.
--- There is currently no API to get e.g. the timeval socket options
+-- | Get a socket option that gives an 'Int' value.
 getSocketOption :: Socket
                 -> SocketOption  -- Option Name
                 -> IO Int        -- Option Value
@@ -396,8 +394,8 @@
 -- | Get a socket option.
 getSockOpt :: forall a . Storable a
            => Socket
-           -> SocketOption  -- Option Name
-           -> IO a        -- Option Value
+           -> SocketOption -- Option Name
+           -> IO a         -- Option Value
 getSockOpt s (SockOpt level opt) = do
     alloca $ \ptr -> do
         let sz = fromIntegral $ sizeOf (undefined :: a)
diff --git a/Network/Socket/Types.hsc b/Network/Socket/Types.hsc
--- a/Network/Socket/Types.hsc
+++ b/Network/Socket/Types.hsc
@@ -1151,7 +1151,9 @@
 pokeSockAddr :: Ptr a -> SockAddr -> IO ()
 #if defined(DOMAIN_SOCKET_SUPPORT)
 pokeSockAddr p sa@(SockAddrUnix path) = do
-    when (length path > unixPathMax) $ error "pokeSockAddr: path is too long"
+    when (length path > unixPathMax) $ error
+      $ "pokeSockAddr: path is too long in SockAddrUnix " <> show path
+      <> ", length " <> show (length path) <> ", unixPathMax " <> show unixPathMax
     zeroMemory p $ fromIntegral $ sizeOfSockAddr sa
 # if defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
     (#poke struct sockaddr_un, sun_len) p ((#const sizeof(struct sockaddr_un)) :: Word8)
@@ -1318,7 +1320,7 @@
 socktypeBijection =
     [ (UnsupportedSocketType, "UnsupportedSocketType")
     , (Stream, "Stream")
-    , (Datagram, "Datagram") 
+    , (Datagram, "Datagram")
     , (Raw, "Raw")
     , (RDM, "RDM")
     , (SeqPacket, "SeqPacket")
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for Haskell network package 3.1.2.8.
+# Generated by GNU Autoconf 2.69 for Haskell network package 3.1.2.9.
 #
 # Report bugs to <libraries@haskell.org>.
 #
@@ -580,8 +580,8 @@
 # Identity of this package.
 PACKAGE_NAME='Haskell network package'
 PACKAGE_TARNAME='network'
-PACKAGE_VERSION='3.1.2.8'
-PACKAGE_STRING='Haskell network package 3.1.2.8'
+PACKAGE_VERSION='3.1.2.9'
+PACKAGE_STRING='Haskell network package 3.1.2.9'
 PACKAGE_BUGREPORT='libraries@haskell.org'
 PACKAGE_URL=''
 
@@ -1234,7 +1234,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Haskell network package 3.1.2.8 to adapt to many kinds of systems.
+\`configure' configures Haskell network package 3.1.2.9 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1299,7 +1299,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Haskell network package 3.1.2.8:";;
+     short | recursive ) echo "Configuration of Haskell network package 3.1.2.9:";;
    esac
   cat <<\_ACEOF
 
@@ -1384,7 +1384,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Haskell network package configure 3.1.2.8
+Haskell network package configure 3.1.2.9
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1910,7 +1910,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Haskell network package $as_me 3.1.2.8, which was
+It was created by Haskell network package $as_me 3.1.2.9, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2259,7 +2259,9 @@
 
 
 
-ac_includes_default="#define _GNU_SOURCE 1  /* for struct ucred on Linux */
+ac_includes_default="#ifndef _WIN32
+# define _GNU_SOURCE 1  /* for struct ucred on Linux */
+#endif
 $ac_includes_default
 
 #ifdef _WIN32
@@ -4417,7 +4419,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Haskell network package $as_me 3.1.2.8, which was
+This file was extended by Haskell network package $as_me 3.1.2.9, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -4470,7 +4472,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-Haskell network package config.status 3.1.2.8
+Haskell network package config.status 3.1.2.9
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -1,10 +1,12 @@
 AC_INIT([Haskell network package],
-        [3.1.2.8],
+        [3.1.2.9],
         [libraries@haskell.org],
         [network])
 
 dnl See also HsNet.h
-ac_includes_default="#define _GNU_SOURCE 1  /* for struct ucred on Linux */
+ac_includes_default="#ifndef _WIN32
+# define _GNU_SOURCE 1  /* for struct ucred on Linux */
+#endif
 $ac_includes_default
 
 #ifdef _WIN32
diff --git a/include/HsNet.h b/include/HsNet.h
--- a/include/HsNet.h
+++ b/include/HsNet.h
@@ -19,7 +19,9 @@
 # endif
 #endif
 
-#define _GNU_SOURCE 1 /* for struct ucred on Linux */
+#ifndef _WIN32
+# define _GNU_SOURCE 1 /* for struct ucred on Linux */
+#endif
 #define __APPLE_USE_RFC_3542 1 /* for IPV6_RECVPKTINFO */
 
 #ifdef _WIN32
diff --git a/network.cabal b/network.cabal
--- a/network.cabal
+++ b/network.cabal
@@ -1,174 +1,194 @@
-cabal-version:  1.18
-name:           network
-version:        3.1.2.8
-license:        BSD3
-license-file:   LICENSE
-maintainer:     Kazu Yamamoto, Evan Borden
-synopsis:       Low-level networking interface
+cabal-version:      1.18
+name:               network
+version:            3.1.2.9
+license:            BSD3
+license-file:       LICENSE
+maintainer:         Kazu Yamamoto, Evan Borden
+
+tested-with:
+    GHC == 9.6.1
+    GHC == 9.4.4
+    GHC == 9.2.7
+    GHC == 9.0.2
+    GHC == 8.10.7
+    GHC == 8.8.4
+    GHC == 8.6.5
+    GHC == 8.4.4
+    GHC == 8.2.2
+    GHC == 8.0.2
+
+homepage:           https://github.com/haskell/network
+bug-reports:        https://github.com/haskell/network/issues
+synopsis:           Low-level networking interface
 description:
-  This package provides a low-level networking interface.
-  .
-  === High-Level Packages
-  Other packages provide higher level interfaces:
-  .
-  * connection
-  * hookup
-  * network-simple
-  .
-  === Extended Packages
-  @network@ seeks to provide a cross-platform core for networking. As such some
-  APIs live in extended libraries. Packages in the @network@ ecosystem are
-  often prefixed with @network-@.
-  .
-  ==== @network-bsd@
-  In @network-3.0.0.0@ the @Network.BSD@ module was split off into its own
-  package, @network-bsd-3.0.0.0@.
-  .
-  ==== @network-uri@
-  In @network-2.6@ the @Network.URI@ module was split off into its own package,
-  @network-uri-2.6@. If you're using the @Network.URI@ module you can
-  automatically get it from the right package by adding this to your @.cabal@
-  file:
-  .
-  > library
-  >   build-depends: network-uri-flag
-category:       Network
-build-type:     Configure
-extra-tmp-files:
-  config.log config.status autom4te.cache network.buildinfo
-  include/HsNetworkConfig.h
+    This package provides a low-level networking interface.
+    .
+    === High-Level Packages
+    Other packages provide higher level interfaces:
+    .
+    * connection
+    * hookup
+    * network-simple
+    .
+    === Extended Packages
+    @network@ seeks to provide a cross-platform core for networking. As such some
+    APIs live in extended libraries. Packages in the @network@ ecosystem are
+    often prefixed with @network-@.
+    .
+    ==== @network-bsd@
+    In @network-3.0.0.0@ the @Network.BSD@ module was split off into its own
+    package, @network-bsd-3.0.0.0@.
+    .
+    ==== @network-uri@
+    In @network-2.6@ the @Network.URI@ module was split off into its own package,
+    @network-uri-2.6@. If you're using the @Network.URI@ module you can
+    automatically get it from the right package by adding this to your @.cabal@
+    file:
+    .
+    > library
+    >   build-depends: network-uri-flag
+
+category:           Network
+build-type:         Configure
+
+extra-doc-files:
+    README.md
+    CHANGELOG.md
+
 extra-source-files:
-  README.md CHANGELOG.md
-  examples/*.hs tests/*.hs config.guess config.sub install-sh
-  configure.ac configure
-  include/HsNetworkConfig.h.in include/HsNet.h include/HsNetDef.h
-  -- C sources only used on some systems
-  cbits/asyncAccept.c cbits/initWinSock.c
-  cbits/winSockErr.c cbits/cmsg.c
-homepage:       https://github.com/haskell/network
-bug-reports:    https://github.com/haskell/network/issues
-tested-with:   GHC == 8.0.2
-             , GHC == 8.2.2
-             , GHC == 8.4.4
-             , GHC == 8.6.5
-             , GHC == 8.8.3
-             , GHC == 8.10.1
+    examples/*.hs
+    tests/*.hs
+    config.guess
+    config.sub
+    install-sh
+    configure.ac
+    configure
+    include/HsNetworkConfig.h.in
+    include/HsNet.h
+    include/HsNetDef.h
+    cbits/asyncAccept.c
+    cbits/initWinSock.c
+    cbits/winSockErr.c
+    cbits/cmsg.c
 
+extra-tmp-files:
+    config.log
+    config.status
+    autom4te.cache
+    network.buildinfo
+    include/HsNetworkConfig.h
+
+source-repository head
+    type:     git
+    location: https://github.com/haskell/network.git
+
 flag devel
-  description:          using tests for developers
-  default:              False
+    description: using tests for developers
+    default:     False
 
 library
-  default-language: Haskell2010
-  exposed-modules:
-    Network.Socket
-    Network.Socket.Address
-    Network.Socket.ByteString
-    Network.Socket.ByteString.Lazy
-    Network.Socket.Internal
-  other-modules:
-    Network.Socket.Buffer
-    Network.Socket.ByteString.IO
-    Network.Socket.ByteString.Internal
-    Network.Socket.Cbits
-    Network.Socket.Fcntl
-    Network.Socket.Flag
-    Network.Socket.Handle
-    Network.Socket.If
-    Network.Socket.Imports
-    Network.Socket.Info
-    Network.Socket.Name
-    Network.Socket.Options
-    Network.Socket.ReadShow
-    Network.Socket.Shutdown
-    Network.Socket.SockAddr
-    Network.Socket.Syscall
-    Network.Socket.Types
-    Network.Socket.Unix
+    exposed-modules:
+        Network.Socket
+        Network.Socket.Address
+        Network.Socket.ByteString
+        Network.Socket.ByteString.Lazy
+        Network.Socket.Internal
 
-  build-depends:
-    base >= 4.9 && < 5,
-    bytestring >= 0.10 && < 0.12,
-    deepseq,
-    directory
+    build-tools:      hsc2hs >=0
+    c-sources:
+        cbits/HsNet.c
+        cbits/cmsg.c
 
-  include-dirs: include
-  includes: HsNet.h HsNetDef.h alignment.h win32defs.h
-  install-includes: HsNet.h HsNetDef.h  alignment.h win32defs.h
-  c-sources: cbits/HsNet.c cbits/cmsg.c
-  ghc-options: -Wall -fwarn-tabs
-  build-tools: hsc2hs
+    other-modules:
+        Network.Socket.Buffer
+        Network.Socket.ByteString.IO
+        Network.Socket.ByteString.Internal
+        Network.Socket.Cbits
+        Network.Socket.Fcntl
+        Network.Socket.Flag
+        Network.Socket.Handle
+        Network.Socket.If
+        Network.Socket.Imports
+        Network.Socket.Info
+        Network.Socket.Name
+        Network.Socket.Options
+        Network.Socket.ReadShow
+        Network.Socket.Shutdown
+        Network.Socket.SockAddr
+        Network.Socket.Syscall
+        Network.Socket.Types
+        Network.Socket.Unix
 
+    default-language: Haskell2010
+    include-dirs:     include
+    includes:         HsNet.h HsNetDef.h alignment.h win32defs.h
+    install-includes: HsNet.h HsNetDef.h alignment.h win32defs.h
+    ghc-options:      -Wall -fwarn-tabs
+    build-depends:
+        base >=4.9 && <5,
+        bytestring >=0.10 && <0.12,
+        deepseq,
+        directory
 
-  -- Add some platform specific stuff
-  if !os(windows)
-    other-modules:
-      Network.Socket.ByteString.Lazy.Posix
-      Network.Socket.Posix.Cmsg
-      Network.Socket.Posix.CmsgHdr
-      Network.Socket.Posix.IOVec
-      Network.Socket.Posix.MsgHdr
+    if !os(windows)
+        other-modules:
+            Network.Socket.ByteString.Lazy.Posix
+            Network.Socket.Posix.Cmsg
+            Network.Socket.Posix.CmsgHdr
+            Network.Socket.Posix.IOVec
+            Network.Socket.Posix.MsgHdr
 
-  if os(solaris)
-    extra-libraries: nsl, socket
-    cpp-options: -D__EXTENSIONS__ -D_XOPEN_SOURCE=500
-    cc-options: -D__EXTENSIONS__ -D_XOPEN_SOURCE=500
+    if os(solaris)
+        cpp-options:     -D__EXTENSIONS__ -D_XOPEN_SOURCE=500
+        cc-options:      -D__EXTENSIONS__ -D_XOPEN_SOURCE=500
+        extra-libraries:
+            nsl
+            socket
 
-  if os(windows)
-    other-modules:
-      Network.Socket.ByteString.Lazy.Windows
-      Network.Socket.Win32.Cmsg
-      Network.Socket.Win32.CmsgHdr
-      Network.Socket.Win32.WSABuf
-      Network.Socket.Win32.MsgHdr
-    c-sources: cbits/initWinSock.c, cbits/winSockErr.c, cbits/asyncAccept.c
-    extra-libraries: ws2_32, iphlpapi, mswsock
-    -- See https://github.com/haskell/network/pull/362
-    if impl(ghc >= 7.10)
-      cpp-options: -D_WIN32_WINNT=0x0600
-      cc-options: -D_WIN32_WINNT=0x0600
+    if os(windows)
+        c-sources:
+            cbits/initWinSock.c
+            cbits/winSockErr.c
+            cbits/asyncAccept.c
 
-test-suite spec
-  default-language: Haskell2010
-  hs-source-dirs: tests
-  main-is: Spec.hs
-  if flag(devel)
-    cpp-options:  -DDEVELOPMENT
-  other-modules:
-    Network.Test.Common
-    Network.SocketSpec
-    Network.Socket.ByteStringSpec
-    Network.Socket.ByteString.LazySpec
-  type: exitcode-stdio-1.0
-  ghc-options: -Wall -threaded
-  -- NB: make sure to versions of hspec and hspec-discover
-  --     that work together; easiest way is to constraint
-  --     both packages to a small enough version range.
-  build-tools: hspec-discover >= 2.6
-  build-depends:
-    base >= 4.9 && < 5,
-    bytestring,
-    directory,
-    HUnit,
-    network,
-    temporary,
-    hspec >= 2.6,
-    QuickCheck
+        other-modules:
+            Network.Socket.ByteString.Lazy.Windows
+            Network.Socket.Win32.Cmsg
+            Network.Socket.Win32.CmsgHdr
+            Network.Socket.Win32.WSABuf
+            Network.Socket.Win32.MsgHdr
 
-test-suite doctests
-  buildable: False
-  default-language: Haskell2010
-  hs-source-dirs: tests
-  main-is: doctests.hs
-  type: exitcode-stdio-1.0
+        extra-libraries:
+            ws2_32
+            iphlpapi
+            mswsock
 
-  build-depends:
-    base >= 4.9 && < 5,
-    doctest >= 0.10.1,
-    network
+        if impl(ghc >=7.10)
+            cpp-options: -D_WIN32_WINNT=0x0600
+            cc-options:  -D_WIN32_WINNT=0x0600
 
-  ghc-options: -Wall
+test-suite spec
+    type:             exitcode-stdio-1.0
+    main-is:          Spec.hs
+    build-tools:      hspec-discover >=2.6
+    hs-source-dirs:   tests
+    other-modules:
+        Network.Test.Common
+        Network.SocketSpec
+        Network.Socket.ByteStringSpec
+        Network.Socket.ByteString.LazySpec
 
-source-repository head
-  type:     git
-  location: git://github.com/haskell/network.git
+    default-language: Haskell2010
+    ghc-options:      -Wall -threaded
+    build-depends:
+        base >=4.9 && <5,
+        bytestring,
+        directory,
+        HUnit,
+        network,
+        temporary,
+        hspec >=2.6,
+        QuickCheck
+
+    if flag(devel)
+        cpp-options: -DDEVELOPMENT
diff --git a/tests/doctests.hs b/tests/doctests.hs
deleted file mode 100644
--- a/tests/doctests.hs
+++ /dev/null
@@ -1,15 +0,0 @@
-module Main where
-
-import Build_doctests (flags, pkgs, module_sources)
-import Data.Foldable (traverse_)
-import Data.List (isSuffixOf, isPrefixOf)
-import Test.DocTest (doctest)
-
-main :: IO ()
-main = do
-    traverse_ putStrLn args
-    doctest args
-  where
-    builddir = filter ("build" `isSuffixOf`) $ filter ("-i" `isPrefixOf`) flags
-    addinc path = "-I" ++ drop 2 path ++ "/include"
-    args = map addinc builddir ++ flags ++ pkgs ++ module_sources
