diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,7 @@
+## 0.3.2.7
+
+* Fix compilation error with libio.hs [#18](https://github.com/psibi/download/pull/18)
+
 ## 0.3.2.6
 
 * Fix Arch Linux build [#15](https://github.com/psibi/download/pull/15)
diff --git a/cbits/ftp.c b/cbits/ftp.c
--- a/cbits/ftp.c
+++ b/cbits/ftp.c
@@ -64,7 +64,7 @@
 
 #include <ctype.h>
 #ifndef __APPLE__
-#include <libio.h>
+#include <stdio.h>
 #endif
 #include <err.h>
 #include <errno.h>
diff --git a/cbits/http.c b/cbits/http.c
--- a/cbits/http.c
+++ b/cbits/http.c
@@ -68,7 +68,7 @@
 
 #include <ctype.h>
 #ifndef __APPLE__
-#include <libio.h>
+#include <stdio.h>
 #endif
 #include <err.h>
 #include <errno.h>
diff --git a/download.cabal b/download.cabal
--- a/download.cabal
+++ b/download.cabal
@@ -1,67 +1,83 @@
-name: download
-version: 0.3.2.6
-cabal-version: >=1.8
-build-type: Simple
-license: BSD3
-license-file: LICENSE
-copyright: (c) 2008-2011, Don Stewart <dons00@gmail.com>
-maintainer: Sibi Prabakaran <sibi@psibi.in>
-homepage: https://github.com/psibi/download
-bug-reports: https://github.com/psibi/download/issues
-synopsis: High-level file download based on URLs
-description:
-    High-level file download based on URLs
-category: Network
-author: Don Stewart
-tested-with: GHC ==7.10.3
-extra-source-files:
-    ChangeLog.md
-    README.md
+name:            download
+version:         0.3.2.7
+homepage:        https://github.com/psibi/download
+synopsis:        High-level file download based on URLs
+description:     High-level file download based on URLs
+extra-source-files: ChangeLog.md README.md
+bug-reports:     https://github.com/psibi/download/issues
+category:        Network
+license:         BSD3
+license-file:    LICENSE
+copyright:       (c) 2008-2011, Don Stewart <dons00@gmail.com>
+author:          Don Stewart
+maintainer:      Sibi Prabakaran <sibi@psibi.in>
+cabal-version:   >= 1.8
+build-type:      Simple
+tested-with:     GHC ==7.10.3
 
-source-repository head
-    type: git
-    location: https://github.com/psibi/download
+-- flag external
+--  description: Build with an external libdownload
+--  default:     False
 
+Source-Repository head
+    Type: git
+    Location: https://github.com/psibi/download
+
 library
-    exposed-modules:
-        Network.Download
-    build-depends:
-        base >=3 && <5,
-        bytestring -any,
-        tagsoup >=0.8,
-        feed -any,
-        xml -any
-    cc-options: -O2 -DINET6 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-                -UDEBUG
-    c-sources:
-        cbits/download.c
-        cbits/common.c
-        cbits/ftp.c
-        cbits/http.c
-        cbits/file.c
-        cbits/hs_download_utils.c
-    extensions: CPP ForeignFunctionInterface EmptyDataDecls
-                GeneralizedNewtypeDeriving
-    includes:
-        download.h
-        common.h
-        ftperr.h
-        httperr.h
-        hs_download_utils.h
-    install-includes:
-        common.h
-        download.h
-        ftperr.h
-        httperr.h
-        hs_download_utils.h
-    include-dirs: cbits
-    ghc-options: -Wall
+    exposed-modules: Network.Download
+    extensions:      CPP,
+                     ForeignFunctionInterface,
+                     EmptyDataDecls,
+                     GeneralizedNewtypeDeriving
 
-test-suite  test
-    type: exitcode-stdio-1.0
-    main-is: Spec.hs
-    build-depends:
-        base >=4.5 && <5,
-        download -any,
-        hspec ==2.*
-    ghc-options: -Wall
+    ghc-options:     -Wall
+
+    build-depends:   base >= 3 && < 5, bytestring,
+                     tagsoup >= 0.8, feed, xml
+
+    ------------------------------------------------------------------------
+    -- Building libdownload
+    --
+    -- We can build against either an external libdownload, or an internal one.
+
+--    if flag(external)
+--        extra-libraries:    download
+--        c-sources:          cbits/hs_download_utils.c
+--        include-dirs:       cbits
+--        includes:           hs_download_utils.h
+--        install-includes:   hs_download_utils.h
+--    else
+
+    cc-options:         -O2
+                        -DINET6
+                        -D_GNU_SOURCE
+                        -D_FILE_OFFSET_BITS=64
+                        -UDEBUG
+
+    c-sources:          cbits/download.c
+                        cbits/common.c
+                        cbits/ftp.c
+                        cbits/http.c
+                        cbits/file.c
+                        cbits/hs_download_utils.c
+
+    include-dirs:       cbits
+    includes:           download.h
+                        common.h
+                        ftperr.h
+                        httperr.h
+                        hs_download_utils.h
+
+    install-includes:   common.h
+                        download.h
+                        ftperr.h
+                        httperr.h
+                        hs_download_utils.h
+
+test-suite test
+    type:          exitcode-stdio-1.0
+    ghc-options:   -Wall
+    main-is:       Spec.hs
+    build-depends:   base >= 4.5 && < 5,
+                     download,
+                     hspec == 2.*
