Skip to content

Instantly share code, notes, and snippets.

@RX14
Last active March 9, 2024 17:56
Show Gist options
  • Save RX14/c6ca69bfbe1f21d30d1e0b5ed3c15199 to your computer and use it in GitHub Desktop.
Save RX14/c6ca69bfbe1f21d30d1e0b5ed3c15199 to your computer and use it in GitHub Desktop.
Compile libraries needed for Crystal on Windows
.\vs_buildtools.exe --passive --norestart --wait --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended | Out-Default
$script = @'
$installdir = "$pwd"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
echo "Downloading cmake"
iwr https://cmake.org/files/v3.11/cmake-3.11.4-win64-x64.zip -OutFile cmake.zip
Expand-Archive cmake.zip -DestinationPath .
rm cmake.zip
$cmake = "$installdir\cmake-3.11.4-win64-x64\bin\cmake.exe"
echo "Downloading PCRE"
iwr https://ftp.pcre.org/pub/pcre/pcre-8.42.zip -OutFile pcre.zip
Expand-Archive pcre.zip -DestinationPath .
rm pcre.zip
echo "Building PCRE"
mkdir pcre-8.42\build
cd pcre-8.42\build
& $cmake .. -G "Visual Studio 15 2017 Win64" -DBUILD_SHARED_LIBS=OFF -DPCRE_SUPPORT_UNICODE_PROPERTIES=ON -DPCRE_SUPPORT_JIT=ON -DPCRE_STATIC_RUNTIME=ON | Out-Default
& $cmake --build . --config release | Out-Default
mv release\pcre.lib $installdir\pcre.lib
cd $installdir
echo "Downloading libgc"
iwr https://github.com/ivmai/bdwgc/archive/v7.6.6.zip -OutFile bdwgc.zip
Expand-Archive bdwgc.zip -DestinationPath .
rm bdwgc.zip
echo "Downloading libatomic_ops"
iwr https://github.com/ivmai/libatomic_ops/archive/v7.6.4.zip -OutFile libatomic_ops.zip
Expand-Archive libatomic_ops.zip -DestinationPath .
rm libatomic_ops.zip
mv libatomic_ops-7.6.4 bdwgc-7.6.6\libatomic_ops
echo "Downloading win32.mak"
iwr https://gist.github.com/ynkdir/688e62f419e5374347bf/raw/d250598ddf5129addd212b8390279a01bca12706/win32.mak -OutFile bdwgc-7.6.6\ntwin32.mak
echo "Building libgc"
cd bdwgc-7.6.6
nmake -f NT_X64_STATIC_THREADS_MAKEFILE nodebug=1 _CL_=-DDONT_USE_USER32_DLL | Out-Default
mv gc.lib $installdir\gc.lib
'@
$script | cmd /S /C 'C:\Program^ Files^ ^(x86^)\Microsoft^ Visual^ Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat x64 && powershell -Command -'
@Daniel-Worrall
Copy link

Folder is now 2019, not 2017

@Daniel-Worrall
Copy link

I updated cmake & pcre as well as the references of 2017 to 2019 to be usable

.\vs_buildtools.exe --passive --norestart --wait --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended | Out-Default

$script = @'
$installdir = "$pwd"

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

echo "Downloading cmake"
iwr https://cmake.org/files/v3.16/cmake-3.16.4-win64-x64.zip -OutFile cmake.zip
Expand-Archive cmake.zip -DestinationPath .
rm cmake.zip

$cmake = "$installdir\cmake-3.16.4-win64-x64\bin\cmake.exe"

echo "Downloading PCRE"
iwr https://ftp.pcre.org/pub/pcre/pcre-8.44.zip -OutFile pcre.zip
Expand-Archive pcre.zip -DestinationPath .
rm pcre.zip

echo "Building PCRE"
mkdir pcre-8.44\build
cd pcre-8.44\build

& $cmake .. -G "Visual Studio 16 2019" -A x64 -DBUILD_SHARED_LIBS=OFF -DPCRE_SUPPORT_UNICODE_PROPERTIES=ON -DPCRE_SUPPORT_JIT=ON -DPCRE_STATIC_RUNTIME=ON | Out-Default
& $cmake --build . --config release | Out-Default
mv release\pcre.lib $installdir\pcre.lib

cd $installdir

echo "Downloading libgc"
iwr https://github.com/ivmai/bdwgc/archive/v7.6.6.zip -OutFile bdwgc.zip
Expand-Archive bdwgc.zip -DestinationPath .
rm bdwgc.zip

echo "Downloading libatomic_ops"
iwr https://github.com/ivmai/libatomic_ops/archive/v7.6.4.zip -OutFile libatomic_ops.zip
Expand-Archive libatomic_ops.zip -DestinationPath .
rm libatomic_ops.zip
mv libatomic_ops-7.6.4 bdwgc-7.6.6\libatomic_ops

echo "Downloading win32.mak"
iwr https://gist.github.com/ynkdir/688e62f419e5374347bf/raw/d250598ddf5129addd212b8390279a01bca12706/win32.mak -OutFile bdwgc-7.6.6\ntwin32.mak

echo "Building libgc"
cd bdwgc-7.6.6

nmake -f NT_X64_STATIC_THREADS_MAKEFILE nodebug=1 _CL_=-DDONT_USE_USER32_DLL | Out-Default
mv gc.lib $installdir\gc.lib
'@

$script | cmd /S /C 'C:\Program^ Files^ ^(x86^)\Microsoft^ Visual^ Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat x64 && powershell -Command -'

@oprypin
Copy link

oprypin commented Mar 28, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment