There're many ways to install chicken scheme on Windows. I recommend compile it from source. It's because down the road you may need to compile an egg (like what I had to do with openssl egg), you need a matching compiler that matches the one compiled chicken. This avoids a lot of the mystic problems down the road. And as of now, is the only way that worked for me. So here you go.

Compiling Chicken in Mingw

This guide shows how to compile chicken using msys. I recommend msys over vanilla mingw, since mostly the same msys will be needed in the future to compile egg dependencies.

Download chicken source from here. In msys console, unzip to ~/work/chicken. Now determine where on the host system you want to install chicken. I want to install it at c:\chicken, so in msys, do

mkdir /c/chicken
make PLATFORM=mingw-msys PREFIX=/c/chicken
make PLATFORM=mingw-msys PREFIX=/c/chicken install

Once installed, add <mingw>/bin to PATH so chicken executables knows where to find the gcc runtime (libgcc_*). Otherwise, you'll see this error. I tried to compile chicken with gcc option -static-libgcc but the compilation would fail.

And you may need to add the installation path (c:\chicken) in this case to CHICKEN_PREFIX.

tip if you encounter problem with csc, always check CHECK_PREFIX.

Test it out

You can run post-install test according to the README, with

make PLATFORM=mingw-msys PREFIX=/c/chicken check

Also:

  • run csi to test the interpreter
  • run csc to test the compiler
  • try installing extensions with chicken-install <egg>.

Problem installing openssl egg

openssl requires an installation of openssl libraries and the header files accessible by chicken compiler. The easiest way I found is to compile openssl (straightforward) and drop the header files (include/openssl/*) and lib files (libssl.a, libcrypto.a) to chicken directories.

  • headers are at <chicken>/include\chicken
  • libs are at <chicken>/lib

Compiling OpenSSL in Mingw

Download openssl source (v1.0.2k) from here. Extract it to msys home directory. From msys console, follow instruction in INSTALL file:

1
2
./config
make

This compiles libssl.a and libcrypto.a at source root. All header files are copied to include/openssl. They can then be copied to the corresponding chicken directories.

Pending Issues

Extensions cannot be statically linked, e.g., http-client. See this SO question. This blog post offers a way to do this by manually compiling the dependencies with csc, might worth a try. This thread reports a similar problem.

Relevant notes

The below are notes I took along fixing the issues, mostly building eggs. They were actions I took before fully compiling chicken from source. Might still offer some insights.

The chicken binaries (especially csc) is tightly related to the location of the C compiler that compiled it. I got a working copy of chicken and csc by installing it and its depedency mingw from Chocolatey. Chicken is installed at c:\chicken, mingw is installed at c:\tools\mingw.

However, I have problem installing openssl egg. Here documents the attempts to fix them.

Problem: cannot find openssl/rand.h

Initially solved with downloading openssl developer library and extracts headers from OpenSSL for Windows into chicken installation path.

tip Chicken installation structure:

  • headers are at <chicken>/include\chicken
  • libs are at <chicken>/lib

This leads to the next problem. A proper fix for this would be to build openssl from mingw.

Problem: header naming clash**

1
2
C:/chicken/include/chicken/openssl/ossl_typ.h:176:33: error: expected ')' before numeric constant
typedef struct ocsp_response_st OCSP_RESPONSE;

There's header macro name clash (OCSP_RESPONSE) in wincrypto.h and ossl-typ.h. Inspired by this issue on SourceForge1 and its diff attachment, I came up with the following fix for openssl.scm in the egg:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
*** "openssl\\openssl.orig.scm"   Wed Feb 22 01:21:45 2017
--- "openssl\\openssl.scm" Wed Feb 22 01:21:12 2017
***************
*** 62,68 ****
--- 62,79 ----
#ifdef _MSC_VER
#include <winsock2.h>
#else
+
+ #ifndef NOCRYPT
+ #define PODOFO_NO_WINCRYPT
+ #define NOCRYPT
+ #endif
+
#include <ws2tcpip.h>
+
+ #ifdef PODOFO_NO_WINCRYPT
+ #undef NOCRYPT
+ #endif
+
#endif

#include <openssl/rand.h>

Tip to debug chicken installation problem, use

chicken-install -k -debug <egg>

-k keeps the temporary working directory where the egg files are located. It is helpful for allowing subsequent installation from the locally fixed egg files.

Tip to install egg from local directory:

chicken-install -transport local -location C:\Users\username\AppData\Local\Temp\tempd5e8.3100\ openssl

See "other modes of installation".

This leads to the next problem.

Problem: library incompatibility

Now that compilation is successful, the linker couldn't locate libssl and libcrypto. Still solved this issue by dropping these two files from openssl developer library into <chicken>/lib. Now I got library incompatibility at linker stage:

1
2
3
4
C:/tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\chicken\lib\/libssl.a when searching for -lssl
C:/tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lssl
C:/tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\chicken\lib\/libcrypto.a when searching for -lcrypto
C:/tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcrypto

Since I don't know how openssl developer library was compiled, I tried to fix this by compiling openssl from mingw x64 by myself. The compilation is quite straightforward (documented at the bottom). But after copying the libraries over, I still get the same error. Now I'm wondering if the mingw that comes with chicken is not compatible with the one that I use to compile openssl.