diff --git a/configure.ac b/configure.ac
index 799f2731016b9d288d1e85c5ef4b6796792d4e40..8851e0ebf96f381798767eb23aecd62804de5345 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,7 +6,7 @@
 AC_INIT([cjose], [0.6.1])
 AM_INIT_AUTOMAKE([foreign])
 LT_PREREQ([2.2])
-LT_INIT([dlopen])
+LT_INIT([win32-dll])
 AC_CONFIG_MACRO_DIR([m4])
 
 ### Basic program checks
diff --git a/src/concatkdf.c b/src/concatkdf.c
index 65c49766c6db6f151ee2788a1600475ca83ddf0d..1f76566bd0af8f80d814f82fb943a5eb7e1bbac8 100644
--- a/src/concatkdf.c
+++ b/src/concatkdf.c
@@ -7,7 +7,11 @@
 
 #include "include/concatkdf_int.h"
 
+#ifdef _WIN32
+#include <Winsock2.h>
+#else
 #include <arpa/inet.h>
+#endif
 #include <openssl/evp.h>
 #include <string.h>
 #include <cjose/base64.h>
diff --git a/src/Makefile.am b/src/Makefile.am
index a855d3b3f7e49231ffb1d1794aeaf57ddf301207..2d19ff68257bdb37fc443f67c70ddd592f35e7d7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,7 +2,7 @@ AM_CFLAGS =-std=gnu99 --pedantic -Wall -Werror -g -O2 -I$(top_builddir)/include
 
 lib_LTLIBRARIES=libcjose.la
 libcjose_la_CPPFLAGS= -I$(topdir)/include
-libcjose_la_LDFLAGS= -lm
+libcjose_la_LDFLAGS= -lm -lws2_32 -no-undefined
 libcjose_la_SOURCES=version.c \
 					util.c \
 					base64.c \
diff --git a/test/check_concatkdf.c b/test/check_concatkdf.c
index e4325fc1a59ab6aef7c4dc783a35ef1ddd61c69a..45841996fc42d926bafa8260cf6b4ea38e111d8e 100644
--- a/test/check_concatkdf.c
+++ b/test/check_concatkdf.c
@@ -9,7 +9,11 @@
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
+#ifdef _WIN32
+#include <Winsock2.h>
+#else
 #include <arpa/inet.h>
+#endif
 #include <cjose/base64.h>
 #include <cjose/error.h>
 #include <cjose/header.h>
diff --git a/test/check_jwe.c b/test/check_jwe.c
index 459dce1cd4a6bae2c467427180483c0fc5d661eb..bd8ba3605a7034012c751dc6f3ad820b81ce9a18 100644
--- a/test/check_jwe.c
+++ b/test/check_jwe.c
@@ -269,7 +269,7 @@ START_TEST(test_cjose_jwe_self_encrypt_self_decrypt_many)
     // encrypt and decrypt a whole lot of randomly sized payloads
     for (int i = 0; i < 100; ++i)
     {
-        size_t len = random() % 1024;
+        size_t len = rand() % 1024;
         char *plain = (char *)malloc(len);
         ck_assert_msg(RAND_bytes(plain, len) == 1, "RAND_bytes failed");
         plain[len - 1] = 0;
diff --git a/test/check_jws.c b/test/check_jws.c
index 869c3bfb3cba5922356b1be31819916f1208b0d7..57b0773fcc12c9718c070b7f37404bc7c3582cfe 100644
--- a/test/check_jws.c
+++ b/test/check_jws.c
@@ -201,7 +201,7 @@ START_TEST(test_cjose_jws_self_sign_self_verify_many)
     // sign and verify a whole lot of randomly sized payloads
     for (int i = 0; i < 100; ++i)
     {
-        size_t len = random() % 1024;
+        size_t len = rand() % 1024;
         char *plain = (char *)malloc(len);
         ck_assert_msg(RAND_bytes(plain, len) == 1, "RAND_bytes failed");
         plain[len - 1] = 0;
