mysqlclient-sys
mysqlclient-sys copied to clipboard
Docs suggestion: Instructions for building on Windows (e.g. via github actions)
I'm currently fighting through the best way to get libmysql available on GH actions to test with Windows, and I can't be the only one.
I've attempted installng via vcpkg which seems to be more or less what the CI here does (this is updated for powershell as gh actions now use)
$VCPKG_ROOT = "c:\projects\vcpkg"
git clone https://github.com/Microsoft/vcpkg --depth 1 $VCPKG_ROOT
& "${VCPKG_ROOT}\bootstrap-vcpkg.bat"
& "${VCPKG_ROOT}\vcpkg.exe" install libmysql
But hit the issue libmysql[core]:x86-windows is only supported on '!(windows & x86) & !uwp'
If I figure out a way around this, I will update this issue and create a PR.
Any suggestions are appreciated until then
Ok, turns out gh actions already has vcpkg installed for windows. This is painfully slow so far
echo "vcpkg root: ${VCPKG_ROOT}"
echo "vcpkg install: ${VCPKG_INSTALLATION_ROOT}"
& c:\vcpkg\vcpkg.exe install libmysql:x64-windows
It turns out that the GH image actually ships with MySQL but the linker doesn't know where to look. Setting the following environment variable works:
env:
MYSQLCLIENT_LIB_DIR: C:\mysql\lib
Maybe it would be good to add that to the search path?
For any other windows-based build where mysql isn't preinstalled, the required libary can be downloaded from a zip:
curl -L https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.31-winx64.zip -o mysql-installer.zip
Once extracted, the DLLs/LIBs are in mysql-8.0.31-winx64\lib, and that can be set to the environment variable
See here for diesels CI setup.
Otherwise I'm happy to merge PR's adding documentation and/or a CI configuration to this repo as well.
Thanks for the link. I learned that the windows images actually have mysql installed already, so the choco install isn't even needed https://github.com/actions/runner-images/blob/main/images/win/Windows2022-Readme.md#database-tools
I will create a PR at some point to add some hints about this
Github must have changed something. On windows-latest C:\mysql\lib doesn't exist, so the location needs to be changed:
MYSQLCLIENT_LIB_DIR: 'C:\Program Files\MySQL\MySQL Server 8.0\lib'
# will be accepted by a later Diesel version
MYSQLCLIENT_LIB_DIR_X86_64_PC_WINDOWS_MSVC: 'C:\Program Files\MySQL\MySQL Server 8.0\lib'
Docs and CI are there now for vpkg and zip.