« Previous

Building OpenSmalltalk VM for Pharo on Win 7

3 February 2019

I had the occasion to reinstall Windows 7 on my laptop and took the chance to set it up with the latest development tools. The objective was to build OpenSmalltalk for Pharo and Dolphin Smalltalk on the machine.

Install Visual Studio 2017 Community Edition

This is primarily for building Dolphin Smalltalk. The command line tools come in handy when building SQLite.

I chose to install most VS2017 options and it weighed in at a whopping 50GB of disk space.

Install Cygwin

I installed the 64-bit edition. The following packages are required to build 32-bit OpenSmalltalk.

  • cmake
  • gcc-core
  • gcc-g++
  • libglib2.0-devel
  • libglib2.0
  • make
  • mingw-i686-gcc-core
  • mingw-i686-gcc-g++
  • mingw-i686-headers
  • mingw-i686-runtime
  • patch
  • perl-base
  • wget
  • zip


Jumping ahead a bit, as part of the build process, the OpenSmalltalk build system attempts to copy /usr/i686-w64-mingw32/sys-root/mingw/bin/iconv.dll. On my Cygwin installation, there is no such file, but there does exist /usr/bin/cygiconv-2.dll. To make things simple, I copied /usr/bin/cygiconv-2.dll over to where OpenSmalltalk expects to find it. Looking around the web, I believe cygiconv-2.dll is the correct file.

Build OpenSmalltalk

Start a Cygwin terminal. Clone the OpenSmalltalk VM repo and build the VM.

$ mkdir -p /cygdrive/c/Users/Pierce/source/repos/opensmalltalk
$ cd /cygdrive/c/Users/Pierce/source/repos/opensmalltalk
$ git clone https://github.com/opensmalltalk/opensmalltalk-vm.git
Checking out files: 100% (10541/10541), done.
$ cd opensmalltalk-vm/build.win32x86/pharo.cog.spur
$ ../../scripts/updateSCCSVersions
$ ./mvm -f
<humongous amount of output, much fan noise and heat dissipation from laptop>
$ ls build/vm
btext.o           Pharo.def           sqNamedPrims.o          sqWin32PluginSupport.o
cogit.o           Pharo.exe           sqPath.o            sqWin32Prefs.o
etext.o           Pharo.exe.manifest          sqTextEncoding.o        sqWin32Service.o
FileAttributesPlugin.dll  Pharo.exp           sqTicker.o          sqWin32SpurAlloc.o
FT2Plugin.dll         Pharo.lib           SqueakSSL.dll       sqWin32Stubs.o
gcc3x-cointerp.o      Pharo.map           sqVirtualMachine.o      sqWin32Threads.o
iconv.dll         Pharo.res           sqWin32Alloc.o          sqWin32Time.o
libcairo-2.dll        PharoConsole.exe        sqWin32Backtrace.o      sqWin32Utils.o
libeay32.dll          PharoConsole.exe.manifest   sqWin32DirectInput.o    sqWin32VMProfile.o
libfreetype.dll       PharoConsole.map        sqWin32Directory.o      sqWin32Window.o
libgcc_s_sjlj-1.dll   PharoConsoleUnstripped.exe  sqWin32DnsInfo.o        ssleay32.dll
libgit2.dll       PharoUnstripped.exe         sqWin32Exports.o        SurfacePlugin.dll
libpixman-1-0.dll     resource.o              sqWin32ExternalPrims.o  version.o
libpng16-16.dll       SDL2.dll            sqWin32GUID.o       zlib1.dll
libssh2-1.dll         sqExternalSemaphores.o      sqWin32Heartbeat.o
libwinpthread-1.dll   sqHeapMap.o             sqWin32Main.o

Now open a cmd.exe window and copy the VM files out.

C:\> mkdir c:\pkg\pharo6vm32
C:\> copy c:\Users\Pierce\source\repos\opensmalltalk\opensmalltalk-vm\build.win32x86\pharo.cog.spur\build\vm\*.dll c:\pkg\pharo6vm32
C:\> copy c:\Users\Pierce\source\repos\opensmalltalk\opensmalltalk-vm\build.win32x86\pharo.cog.spur\build\vm\*.exe c:\pkg\pharo6vm32
C:\>dir /d c:\pkg\pharo6vm32
 Volume in drive C has no label.
 Volume Serial Number is FCE0-E161

 Directory of c:\pkg\pharo6vm32

[.]                          libssh2-1.dll
[..]                         libwinpthread-1.dll
FileAttributesPlugin.dll     Pharo.exe
FT2Plugin.dll                PharoConsole.exe
iconv.dll                    PharoConsoleUnstripped.exe
libcairo-2.dll               PharoUnstripped.exe
libeay32.dll                 SDL2.dll
libfreetype.dll              SqueakSSL.dll
libgcc_s_sjlj-1.dll          ssleay32.dll
libgit2.dll                  SurfacePlugin.dll
libpixman-1-0.dll            zlib1.dll
              21 File(s)     47,771,093 bytes
               2 Dir(s)  29,938,479,104 bytes free

Build SQLite DLL

Download and unpack the SQLite source amalgamation. The how to compile SQLite page states to use the following MSVC command:

cl sqlite3.c -link -dll -out:sqlite3.dll

While this produces a DLL, said DLL doesn't actually export any symbol and is thus useless for FFI. This blog post by Mario Guggenberger provides the magic incantation:

cl sqlite3.c -DSQLITE_API=__declspec(dllexport) -link -dll -out:sqlite3.dll

To get to the 32-bit MSVC command line tools, click through the following: Windows Menu, All Programs, Visual Studio 2017, Visual Studio Tools, VC, x86 Native Tools Command Prompt. This launches a cmd.exe shell with the appropriate tools set up.

Build sqlite3.dll and copy it to c:\pkg\pharo6vm32.

Test with Pharo 7

Download the Pharo 7 32-bit image zip. Unpack and make a copy - I named the image file wintesting. Double click on c:\pkg\pharo6vm32\Pharo.exe and choose wintesting.image to start.

In Pharo, open Catalog Browser. Select and install GlorpSQLite. It fails. Run below Metacello snippet, which is what is executed when loading GlorpSQLite from Catalog Browser.

Metacello new
  baseline: 'GlorpSQLite';
  repository: 'github://PierceNg/glorp-sqlite3:pharo7';

Fails with message "The handle is in the wrong state for the requested operation".


There is a related Iceberg issue on GH. The suggestion is to use a newer version of libgit2.

Build newer libgit2

The current version of libgit2 used is 0.25.1, according to opensmalltalk-vm/third-party/libgit2.spec.


According to libgit2 GH repo, the newest versions are 0.27.8 and 0.26.8.

I first tried 0.27.8 but building failed. I then tried 0.26.8 and this time it built successfully. This is what libgit2.spec looks like now:


To build the newer version of libgit2 and the rest of the VM, re-run ./mvm -f in build.win32x86\pharo.cog.spur. When done, copy the .exe and .dll files into c:\pkg\pharo6vm32.

2nd Test

Start Pharo again and repeat steps described above in section Test with Pharo 7. This time Catalog Browser loads GlorpSQLite successfully.

GlorpSQLite on Pharo 7 on Windows 7

Open Test Runner and run Glorp tests. All tests pass.

GlorpSQLite3 on Pharo 7 on Windows 7

Blog comments powered by Disqus