Installing the Go Chilkat Package on Windows
Prerequisites
Installing 7-Zip and CURL will make it easier to automate the installation of the Chilkat Package for Go. You'll also need a MinGW or TDM-gcc compiler installed because Chilkat links against a native "C" Chilkat library.
7-Zip
Go to https://www.7-zip.org/ and install 7-Zip. After installing, add "C:\Program Files\7-Zip" to your PATH environment variable. I recommend using the Rapid Environment Editor to manage your PATH environment variable. After installing and updating PATH, you should have the "7z" command. Open a command prompt and type "7z -?" to verify.
curl for Windows
First check to see if you have curl already installed. Open a command prompt and type "curl -V". If you see a reported version, then you have nothing to do. Otherwise, go to https://curl.se/windows/ and download/unzip to any directory on Windows. Then add the "bin" directory to your PATH. For example, I downloaded and unzipped to "C:\commandLineApps\curl-8.2.1_7-win64-mingw" and added "C:\commandLineApps\curl-8.2.1_7-win64-mingw\bin" to my PATH. After updating your PATH, open a command prompt and type "curl -V" to verify.
gcc
You'll need a MinGW or TDM-gcc gcc compiler for Go to build the Chilkat package. Open a command prompt and type "gcc --version". If you have a MinGW-w64 or TDM-gcc compiler that is not too old, then all should be good. These instructions will assume you don't, and will guide you to download and install the tdm-gcc compiler.
Go to https://jmeubank.github.io/tdm-gcc/download/ and download/install tdm64-gcc-10.3.0-2.exe. (The version may have updated since these instructions were written. That's OK, just download the latest version for your 64-bit Windows. Use the defaults.)
If c:\TDM-GCC-64\bin was not added to your PATH, then add it.
Open a command prompt and type "gcc --version" to verify.
Go
The following instructions were tested with Go v1.21.0. If you are using an older version of Go, I'd recommend updating to the latest version before attempting to install/build the Chilkat Go package.
Installing
Step 1: Download the Install Scripts
Download build_chilkat_go.zip to any directory, preferably on the "C" drive.
Step 2: Unzip
Unzip the build_chilkat_go.zip archive. You will see a build_on_windows subdirectory.
Step 3: Open Command Prompt in the build_on_windows subdirectory
Open a DOS command prompt in the build_on_windows subdirectory.
Step 4: Run the install_on_windows.bat script.
The install_on_windows.bat script will download and install the chilkat Go package. It will also verify the downloads have the expected SHA256 checksum. To ease your worries, I am presenting the contents of the script below, for you to review.
Step 5: Build chilkat_example1 and chilkat_example2
There are two additional .bat scripts: build_example1.bat and build_example2.bat. Run these to build each example. These scripts do not download anything. (The 1st build will take some time, but subsequent builds do not.)
The install_on_windows.bat script contains the following:
REM @ECHO OFF REM This is the install .bat script for the Chilkat v10.0.0 Go module on Windows. REM This assumes 64-bit Windows. SET "InitialDir=%CD%" REM The InstallDir will be automatically created if it does not yet exist. REM HOMEPATH does not contain the drive letter. If running this script REM from a different drive letter, make sure to include "C:" SET InstallDir=C:%HOMEPATH% REM ------------------------------------------------------------------------------ REM Check for prerequisites. We need 7z, curl, and gcc commands to be present. REM See https://www.chilkatsoft.com/go_windows.asp WHERE 7z IF %ERRORLEVEL% EQU 0 ( ECHO Good, 7z Exists ) ELSE ( ECHO 7z does not exist. See https://www.chilkatsoft.com/go_windows.asp GOTO :ErrorExit ) WHERE curl IF %ERRORLEVEL% EQU 0 ( ECHO Good, curl Exists ) ELSE ( ECHO curl does not exist. See https://www.chilkatsoft.com/go_windows.asp GOTO :ErrorExit ) WHERE gcc IF %ERRORLEVEL% EQU 0 ( ECHO Good, gcc Exists ) ELSE ( ECHO gcc does not exist. See https://www.chilkatsoft.com/go_windows.asp GOTO :ErrorExit ) REM The certutil command should already exist on a Windows system. REM We're checking it here to be sure.. REM We'll be using certutil to check the SHA256 hash of the files we download from chilkatdownload.com WHERE certutil IF %ERRORLEVEL% EQU 0 ( ECHO Good, certutil Exists ) ELSE ( ECHO certutil does not exist. GOTO :ErrorExit ) REM ------------------------------------------------------------------------------ REM Check to see if we have TDM or MinGW-w64. REM Chilkat updates this script with each new version with the expected SHA256 of the .tar.gz file. gcc --version | FIND "tdm64" IF ERRORLEVEL 1 ( SET NativeCLibUrl=https://chilkatdownload.com/10.0.0/chilkatext-mingw-x86_64-10.0.0-posix-seh.tar.gz SET CLibSHA256=d330a289b0356de2c564ca9da97d755789c438b1d438794c2cba534d3f57c8d8 SET CLibSubdir=x86_64-10.0.0-posix-seh ECHO Assuming MinGW-W64... ) ELSE ( SET NativeCLibUrl=https://chilkatdownload.com/10.0.0/chilkatext-tdm-gcc-64-10.3.0.tar.gz SET CLibSHA256=93edd4e59feb61c229c02c0212f1586f65a5b46abccf5bd96a29d66daa3b59bf SET CLibSubdir=tdm-gcc-64-10.3.0 ECHO Looks like you have tdm-gcc installed. Good. ) REM ------------------------------------------------------------------------------ REM Go to the InstallDir and create the "chilkatsoft.com" directory if it does not yet exist. REM (Put %InstallDir% in quotes in case there are SPACE chars in the path.) IF NOT EXIST "%InstallDir%" ( ECHO Creating %InstallDir% ... MKDIR "%InstallDir%" IF ERRORLEVEL 1 ( ECHO Failed to MKDIR %InstallDir% GOTO :ErrorExit ) ) REM The /d flag is necessary when a drive letter is in the path... CD /d "%InstallDir%" REM Create the chilkatsoft.com sub-directory if needed. SET subdir=chilkatsoft.com IF NOT EXIST "%subdir%" ( ECHO Creating %subdir% subdirectory ... MKDIR "%subdir%" IF ERRORLEVEL 1 ( ECHO Failed to MKDIR %subdir% GOTO :ErrorExit ) ) CD "%subdir%" ECHO Current Directory: %CD% REM We are going to download the Chilkat Native "C" library into the chilkatsoft.com\native_c_lib directory SET nativecdir=native_c_lib IF NOT EXIST "%nativecdir%" ( ECHO Creating %nativecdir% subdirectory ... MKDIR "%nativecdir%" IF ERRORLEVEL 1 ( ECHO Failed to MKDIR %nativecdir% GOTO :ErrorExit ) ) CD "%nativecdir%" ECHO Current Directory: %CD% REM ------------------------------------------------------------------------------ REM Delete anything from previous installs. if EXIST chilkat_native_c.tar.gz ( DEL chilkat_native_c.tar.gz ) if EXIST chilkat_native_c.tar ( DEL chilkat_native_c.tar ) if EXIST libchilkatExt.a ( DEL libchilkatExt.a ) if EXIST "%CLibSubdir%" ( RMDIR /S /Q "%CLibSubdir%" ) REM download the native "C" lib, check the SHA256 hash, and extract. REM This is where we'll need the curl and 7z commands, and also certutil. curl %NativeCLibUrl% -o chilkat_native_c.tar.gz REM Verify the file we downloaded has the expected SHA256 digest. certutil -hashfile chilkat_native_c.tar.gz SHA256 | FIND "%CLibSHA256%" IF ERRORLEVEL 1 ( ECHO The C library download does not have the expected SHA256 digest. GOTO :ErrorExit ) ECHO Good, the downloaded native C library (.tar.gz) has the expected SHA256 digest. REM ------------------------------------------------------------------------------ REM Extract the C native library. REM extract from .gz to .tar 7z x chilkat_native_c.tar.gz REM extract the .a static lib from the .tar 7z x chilkat_native_c.tar REM delete the .tar and .tar.gz DEL chilkat_native_c.tar.gz DEL chilkat_native_c.tar REM move the .a static lib up one directory level MOVE "%CLibSubdir%"\libchilkatExt.a libchilkatExt.a REM cleanup if EXIST "%CLibSubdir%" ( RMDIR /S /Q "%CLibSubdir%" ) REM ------------------------------------------------------------------------------ SET CGO_LDFLAGS=-L${SRCDIR}/../native_c_lib -lchilkatExt -lws2_32 -lstdc++ REM move back up to the chilkatsoft.com directory. CD .. REM ------------------------------------------------------------------------------ REM Download the chilkat_go.zip, check the SHA256 digest, and unzip REM First cleanup from any previous installs if EXIST "chilkat" ( RMDIR /S /Q "chilkat" ) if EXIST "chilkat_example1" ( RMDIR /S /Q "chilkat_example1" ) if EXIST "chilkat_example2" ( RMDIR /S /Q "chilkat_example2" ) if EXIST chilkat_go.zip ( DEL chilkat_go.zip ) if EXIST license.pdf ( DEL license.pdf ) curl https://chilkatdownload.com/10.0.0/chilkat_go.zip -o chilkat_go.zip certutil -hashfile chilkat_go.zip SHA256 | FIND "145a00b66fffd3ce5b521044c3e0ce15631ce3b1544613e5fb657134454ae24c" IF ERRORLEVEL 1 ( ECHO The chilkat_go.zip does not have the expected SHA256 digest. GOTO :ErrorExit ) ECHO Good, the downloaded chilkat_go.zip has the expected SHA256 digest. REM extract the files. 7z x chilkat_go.zip REM cleanup if EXIST chilkat_go.zip ( DEL chilkat_go.zip ) REM ------------------------------------------------------------------------------ ECHO Let's build the Chilkat module... ECHO This can take a minute or two, or three... CD chilkat go mod init chilkatsoft.com/chilkat go build CD /d %InitialDir% ECHO Successfully installed the Chilkat Go module on Windows GOTO :EOF :ErrorExit CD /d %InitialDir% ECHO Failed