Reputation: 24166
I am trying to build hlibgit2
on windows. It's a wrapper around a c library, libgit2
. After locating and installing the c dependencies the recommended cabal
from ghcup
can't find include files that are in /usr/include
. This seems trivial. Surely I must be missing something big.
The cabal file for hlibgit2
lists additional c dependencies with extra-libraries
:
extra-libraries:
ws2_32, regex, winhttp, crypt32, rpcrt4, ssl, crypto
Running cabal build
in the mingw64
msys2 terminal on a fairly fresh ghcup installation resulted in the following
Error: cabal-3.10.3.0.exe: Missing dependencies on foreign libraries:
* Missing (or bad) C libraries: regex, ssl, crypto
This problem can usually be solved by installing the system packages that
provide these libraries (you may need the "-dev" versions). If the libraries
are already installed but in a non-standard location then you can use the
flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are.If
the library files do exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
regex
After some difficulty I was able to locate where regex.h
is in msys2. It includes the following include file
/mingw64/include/regex.h
I installed the corresponding msys2 package with pacman
.
pacman --noconfirm -S mingw-w64-x86_64-libsystre
Rerunning cabal build
removes regex
from the list of missing libraries, as expected.
Since ssl.h
is a tiny bit easier to find and is also where crypto.h
comes from I also installed openssl-devel
pacman --noconfirm -S openssl-devel
It includes the following files (among many others)
/usr/include/openssl/crypto.h
/usr/include/openssl/ssl.h
Rerunning cabal build
does not find ssl
or crypto
. Rerunning it with -v3
as suggested by the error message reveals that cabal isn't trying to include headers from /usr/include
:
Running: "C:\ghcup\ghc\9.4.8\lib\../mingw/bin\clang.exe"
"--rtlib=compiler-rt" "-D_UCRT"
"-IC:\ghcup\ghc\9.4.8\lib\../mingw/include"
"-fuse-ld=lld" "--rtlib=compiler-rt" "-D_UCRT"
"-LC:\ghcup\ghc\9.4.8\lib\../mingw/lib"
"-LC:\ghcup\ghc\9.4.8\lib\../mingw/x86_64-w64-mingw32/lib"
"C:\ghcup\msys64\tmp\ghc6DB7.c" "-o" "C:\ghcup\msys64\tmp\ghc6DB8"
"-lcrypto"
"-LC:\ghcup\msys64\mingw64\lib"
"-LC:\cabal\store\ghc-9.4.8\zlib-0.7.0.0-d2a93d80eb2a797e52d57c85d77b6e24ad2240b4\lib"
"-LC:\ghcup\msys64\mingw64\lib"
"-LC:\ghcup\ghc\9.4.8\lib\x86_64-windows-ghc-9.4.8\bytestring-0.11.5.3"
"-LC:\ghcup\ghc\9.4.8\lib\x86_64-windows-ghc-9.4.8\template-haskell-2.19.0.0"
"-LC:\ghcup\ghc\9.4.8\lib\x86_64-windows-ghc-9.4.8\pretty-1.1.3.6"
"-LC:\ghcup\ghc\9.4.8\lib\x86_64-windows-ghc-9.4.8\ghc-boot-th-9.4.8"
"-LC:\ghcup\ghc\9.4.8\lib\x86_64-windows-ghc-9.4.8\deepseq-1.4.8.0"
"-LC:\cabal\store\ghc-9.4.8\bindings-DSL-1.0.25-187bcd9b3e2210e6eff5543318f9f7a5f5429c7b\lib"
"-LC:\ghcup\ghc\9.4.8\lib\x86_64-windows-ghc-9.4.8\array-0.5.4.0"
"-LC:\ghcup\ghc\9.4.8\lib\x86_64-windows-ghc-9.4.8\base-4.17.2.1"
"-LC:\ghcup\ghc\9.4.8\lib\x86_64-windows-ghc-9.4.8\ghc-bignum-1.3"
"-LC:\ghcup\ghc\9.4.8\lib\x86_64-windows-ghc-9.4.8\ghc-prim-0.9.1"
"-LC:\ghcup\ghc\9.4.8\lib\x86_64-windows-ghc-9.4.8\rts-1.0.2"
with environment: [
("CABAL_DIR","C:\\cabal"),
("CONFIG_SITE","C:/ghcup/msys64/etc/config.site"),
("GHCUP_INSTALL_BASE_PREFIX","C:\\"),
("GHCUP_MSYS2_ENV","MINGW64"),
("HASKELL_DIST_DIR","G:\\Dev\\gitlib\\hlibgit2\\dist-newstyle\\build\\x86_64-windows\\ghc-9.4.8\\hlibgit2-0.18.0.16"),
("HLIBGIT2_DATADIR","G:\\Dev\\gitlib\\hlibgit2\\.\\."),
("MINGW_CHOST","x86_64-w64-mingw32"),
("MINGW_PACKAGE_PREFIX","mingw-w64-x86_64"),
("MINGW_PREFIX","C:/ghcup/msys64/mingw64"),
("MSYSCON","mintty.exe"),
("MSYSTEM","MINGW64"),("MSYSTEM_CARCH","x86_64"),("MSYSTEM_CHOST","x86_64-w64-mingw32"),
("MSYSTEM_PREFIX","C:/ghcup/msys64/mingw64"),
("PKG_CONFIG_PATH","C:\\ghcup\\msys64\\mingw64\\lib\\pkgconfig;C:\\ghcup\\msys64\\mingw64\\share\\pkgconfig"),
("PKG_CONFIG_SYSTEM_INCLUDE_PATH","C:/ghcup/msys64/mingw64/include"),
("PKG_CONFIG_SYSTEM_LIBRARY_PATH","C:/ghcup/msys64/mingw64/lib"),
("SHELL","C:\\ghcup\\msys64\\usr\\bin\\bash.exe"),
("TEMP","C:\\ghcup\\msys64\\tmp"),("TMP","C:\\ghcup\\msys64\\tmp"),
("XDG_DATA_DIRS","C:\\ghcup\\msys64\\mingw64\\share\\;C:\\ghcup\\msys64\\usr\\local\\share\\;C:\\ghcup\\msys64\\usr\\share\\"),
("_","C:/ghcup/bin/cabal")
]
C:\ghcup\ghc\9.4.8\lib\../mingw/bin\clang.exe returned ExitFailure 1
C:\ghcup\ghc\9.4.8\lib\../mingw/bin\clang.exe returned ExitFailure 1 with
error message:
lld: error: unable to find library -lcrypto
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
Running cabal user-config diff
results in the following
cabal user-config diff
+ C: \ghcup\msys64\usr\bin
+ extra-include-dirs: C:\ghcup\msys64\mingw64\include
+ extra-lib-dirs: C:\ghcup\msys64\mingw64\lib
+ extra-prog-path: C:\ghcup\bin,
I could edit c:\cabal\config
to list more extra-include-dirs
, but this seems so basic that I must be missing something big. What is it?
Upvotes: 1
Views: 134
Reputation: 24166
There is a much easier way to find pacman
packages.
pacman -Fy
to update the database of pacman packages to search
pacman -F regex.h
to find a package containing regex.h
It seems the only pacman
packages that are useful are those in mingw64
, in this case the package I wanted for openssl is
pacman -F ssl.h
There does not seem to be an easy way to filter pacman packages found by -F
. Specifying --arch
doesn't restrict the architecture, glob patterns don't work for the file, --regex
searches don't take advantage of the index and take forever, and --machinereadable
output isn't machine readable to use with another tool to filter them.
Upvotes: 1