Cannot build project with z3-haskell on windows 10 - haskell

I want to build the haskell bindings for z3 in a Cabal project, the following is the minimum (faulty) example:
Using a project initialized by cabal init:
test/
- Main.hs
- Setup.hs
- CHANGELOG.md
- test.cabal
With modified test.cabal:
cabal-version: 3.0
name: z3-test
version: 0.1.0.0
extra-source-files: CHANGELOG.md
executable test
main-is: Main.hs
build-depends: base >=4.14 && <4.15
, z3 ^>=408.2
default-language: Haskell2010
Z3 binaries are located at C:\z3-4.8.5-x86-win.
Z3-bindings are installed:
cabal v1-install z3 --extra-lib-dirs=C:/z3-4.8.5-x64-win/bin --extra-include-dirs=C:/z3-4.8.5-x64-win/include -v3
All the requested packages are already installed:
z3-408.2
Use --reinstall if you want to reinstall anyway.
Now building the project using:
cabal v2-build --extra-lib-dirs=C:/z3-4.8.5-x64-win/bin --extra-include-dirs=C:/z3-4.8.5-x64-win/include -v3
Results in the error:
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
- z3-408.2 (lib) (requires build)
- z3-test-0.1.0.0 (exe:test) (first run)
Starting z3-408.2 (lib)
Failed to build z3-408.2. The failure occurred during the configure step.
Build log (
C:\cabal\logs\ghc-8.10.2\z3-408.2-1722a25655334afbca91ac935f14ff0d20ccf8c4.log
):
Configuring library for z3-408.2..
cabal.exe: Missing dependency on a foreign library:
* Missing (or bad) header file: z3.h
* Missing (or bad) C library: z3
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
library file does 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.
If the header file does 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.
cabal.exe: Failed to build z3-408.2 (which is required by exe:test from
z3-test-0.1.0.0). See the build log above for details.
How can I build a project with the z3 bindings?
Note that:
GHC version = 8.10.2
Cabal version = 3.2.0.0
I can only use cabal
Using cabal install ... or cabal v2-install ... results in Cannot build .. z3 because none of the components are available to build:

Related

Error building package regex-posix-0.96.0.0 with Stack

I'm trying to compile a new Haskell project with Stack, but I'm getting this error message:
$ stack build
WARNING: Ignoring regex-posix's bounds on base (<0 && >=4.3 && <4.16); using base-4.14.1.0.
Reason: trusting snapshot over cabal file dependency information.
regex-posix > configure
regex-posix > Configuring regex-posix-0.96.0.0...
regex-posix > build
regex-posix > Preprocessing library for regex-posix-0.96.0.0..
regex-posix > compiling .stack-work\dist\274b403a\build\Text\Regex\Posix\Wrap_hsc_make.c failed (exit code 1)
regex-posix > rsp file was: ".stack-work\\dist\\274b403a\\build\\Text\\Regex\\Posix\\hsc5BFC.rsp"
regex-posix > command was: C:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\../mingw/bin\gcc.exe -c .stack-work\dist\274b403a\build\Text\Regex\Posix\Wrap_hsc_make.c -o .stack-work\dist\274b403a\build\Text\Regex\Posix\Wrap_hsc_make.o -D__GLASGOW_HASKELL__=810 -Dmingw32_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dmingw32_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -Icbits -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -I.stack-work\dist\274b403a\build\cbits -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -I.stack-work\dist\274b403a\build\autogen -I.stack-work\dist\274b403a\build\global-autogen -include .stack-work\dist\274b403a\build\autogen\cabal_macros.h -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\bytestring-0.10.12.0\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\base-4.14.1.0\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\integer-gmp-1.0.3.0\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib/include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4/lib/include/
regex-posix > error: Wrap.hsc:96:10: fatal error: regex.h: No such file or directory
regex-posix > compilation terminated.
regex-posix >
Progress 1/2
-- While building package regex-posix-0.96.0.0 (scroll up to its section to see the error) using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_3.2.1.0_ghc-8.10.4.exe --builddir=.stack-work\dist\274b403a build --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
I don't understand the initial warning. When looking at the regex-posix package's dependencies, it does list base (>=4.3 && <4.16) as a dependency, but where does the <0 come from?
I've set the resolver to LTS 18.0 in stack.yaml:
resolver: lts-18.0
According to the documentation of LTS 18.0, it uses base-4.14.1.0. If the versioning is lexicographic, I'd think that 4.14.1.0 fits the range that regex-posix requires (if we, for a moment, ignore the strange <0 constraint).
Here are the relevant parts of my package.yaml:
dependencies:
- base >= 4.7 && < 5
- regex-posix >= 0.96
library:
source-dirs: src
ghc-options:
- -Wall
My stack version:
$ stack --version
Version 2.7.1, Git revision 8afe0c2932716b0441cf4440d6942c59568b6b19 x86_64 hpack-0.34.4
I'm on Windows 10.
FWIW, it's not that I care much about regex-posix in itself. In reality, I'm trying to set up a test project, and test-framework depends on regex-posix.
How can I resolve this issue so that I can compile my code?
The error is not about the version, that is just a warning. The real error is about a missing "regex.h" header for the underlying C library. That header is almost always present on posix platforms (like linux), but not on Windows. See https://github.com/haskell-hvr/regex-posix/issues/4
Particularly this comment by Paul Johnson:
Correction to the above: you don't need mingw64. You just need to install with the _regex-posix-clib flag enabled (note the underscore).
With plain cabal: cabal install regex-posix -f _regex-posix-clib
In Stack, add the following to your stack.yaml:
extra-deps:
- regex-posix-clib-2.7
flags:
regex-posix:
_regex-posix-clib: true
In that thread there is also a comment about the <0 version: https://github.com/haskell-hvr/regex-posix/issues/4#issuecomment-699786233

Cannot install z3 package for Haskell on Windows 10

I'm trying to install a project that uses the z3 package under Windows 10 and haskell stack with the following setup:
The z3 precompiled binaries (with includes under ./z3/includes and dll files under ./z3/bin) are located under the project root
myProject/
- app/
- dist/
- src/
- z3/
- package.yaml
- Setup.hs
- stack.yaml
- myProject.cabal
The package.yaml file contains:
dependencies:
- base >= 4.7 && < 5
- containers
- parsec
- z3 <= 408.0
The stack.yaml file contains:
extra-deps:
- z3-408.0#sha256:89bbc2d828dc1fe1f19666e8e501c69ce5d0ed8026e4a02f7eae1e69f4a352af
extra-include-dirs:
- ./z3/include
extra-lib-dirs:
- ./z3/lib
When I try to stack install I get the following error:
Process exited with code: ExitFailure 1
Logs have been written to: C:\Users\jmueller\repos\synthImp\.stack-work\logs\z3-408.0.log
z3-408.0: configure
Progress 1/2
-- While building package z3-408.0 using:
<...>
--extra-include-dirs=C:\Users\jmueller\repos\synthImp\./z3/include
<...>
--extra-lib-dirs=C:\Users\jmueller\repos\synthImp\./z3/lib
Configuring z3-408.0...
Cabal-simple_Z6RU0evB_2.4.0.1_ghc-8.6.5.exe: Missing dependency on a foreign
library:
* Missing (or bad) C library: z3
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
library file does 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.
The extra include and extra lib dirs are there and obviously the include is found too ... there seems to be a problem on the level of the c compiler
I tried both binaries for z3 (x64 and x86) and I don't know how to capture the output of the c preprocessor for further debugging.
Any help is highly appreciated!
Many thanks in advance

How to add tarball (Cardinality package) to dependency with stack?

I have mylib library package and myapp application. I want to use Cardinality package in mylib which is available only as tarball. So, I added to mylib stack.yaml:
packages:
...
- location: https://hackage.haskell.org/package/Cardinality-0.2/Cardinality-0.2.tar.gz
extra-dep: true
Then I add to mylib's cabal file:
build-depends: ...
, Cardinality
And it's compilable. Now I'm trying to build myapp tool which depends on mylib:
packages:
...
- '../mylib'
But I get error:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for mylib:
Cardinality must match -any, but the stack configuration has no specified version (latest matching version is 0.2)
needed since mylib is a build target.
Some potential ways to resolve this:
* Recommended action: try adding the following to your extra-deps in /home/XXXX/prj/myapp/stack.yaml:
- Cardinality-0.2
* Set 'allow-newer: true' to ignore all version constraints and build anyway.
* You may also want to try using the 'stack solver' command.
Plan construction failed.
So, how to add Cardinality tarball to mylib package in right way?!

Cabal: Does not exists in Windows 8.1

Today I installed windows 8.1 and haskell on my laptop. I'm trying to build my own haskell library, but I got an error when I try to use cabal sdist. This is the error:
D:\Development\School\AFP\Assignments\Practice\Exercise\Project>cabal sdist
Distribution quality errors:
'license: NONE' is not a recognised license. The known licenses are: GPL,
GPL-2, GPL-3, LGPL, LGPL-2.1, LGPL-3, AGPL, AGPL-3, BSD2, BSD3, MIT, ISC,
MPL-2.0, Apache, Apache-2.0, PublicDomain, AllRightsReserved, OtherLicense
Distribution quality warnings:
No 'category' field.
No 'maintainer' field.
No 'synopsis' field.
A 'license-file' is not specified.
When distributing packages it is encouraged to specify source control
information in the .cabal file using one or more 'source-repository' sections.
See the Cabal user guide for details.
Note: the public hackage server would reject this package.
Warning: Cannot run preprocessors. Run 'configure' command first.
Building source dist for Project-0.1.0.0...
cabal: does not exist
Before I used the "cabal sdist" I used the following commands:
cabal init
cabal sandbox init
cabal install -j
Every command succeed, except for the cabal sdist. The cabal install only gives the following warning:
D:\Development\School\AFP\Assignments\Practice\Exercise\Project>cabal install -j
Resolving dependencies...
In order, the following will be installed:
Project-0.1.0.0 (reinstall)
Warning: Note that reinstalls are always dangerous. Continuing anyway...
Notice: installing into a sandbox located at
D:\Development\School\AFP\Assignments\Practice\Exercise\Project\.cabal-sandbox
Configuring Project-0.1.0.0...
Building Project-0.1.0.0...
Installed Project-0.1.0.0
This is my Project.cabal file:
-- Initial Project.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
-- Initial Project.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: Project
version: 0.1.0.0
-- synopsis:
description: Education
license: NONE
-- license-file:
-- author:
-- maintainer:
-- copyright:
-- category:
build-type: Simple
extra-source-files: File6, File5, File4, File3, File2
cabal-version: >=1.10
library
exposed-modules: File1
-- other-modules:
-- other-extensions:
build-depends: base >=4.8 && <4.9, QuickCheck >=2.8 && <2.9
hs-source-dirs: src
default-language: Haskell2010
I tried google, but I can't find a good solution. I use the following versions:
Cabal version: 1.22.4.0
Haskell version: 7.10.2
If you need more information, please ask.
I don't know anything about sdist, but the problem is clear: you've specified 'NONE' as the license in your cabal file, but that is not allowed for the sdist option. configure, build, and init don't care about the specific license, but sdist apparently does.
For more info, I searched google for "cabal sdist" and found this.
This [cabal sdist] has the advantage that Cabal will do a bit more checking, and ensure that the tarball has the structure that HackageDB expects.
HackageDB probably expects a valid license, hence why "NONE" is not allowed.
The problem was that cabal could not find the files in extra-source-files. I thought I didn't had to add the extension of the haskell files, but this is required.
I also had another problem. The extra-source-files wasn't using the hs-source-dirs, so I had to explicitly write "src/" infront of a file.

Cabal: cabal configure fails

This question is only yak-shaving to try and troubleshoot another problem.
So, in an attempt to diagnose another problem of mine, I was advised to try:
cabal unpack base
cd base-4.3.1.0
cabal haddock
To see what that did.
Only, when I did cabal unpack base, it unpacked base-3.0.3.2. Then cabal haddock complained that I needed to run cabal configure first then that failed (lost the exact error, sadly).
So I decided to install base-4.3.1.0, just so I could reenact the instructions exactly.
Even after install, cabal unpack base unpacks base-3.0.3.2, though cabal unpack base-4.3.1.0 unpacks base-4.3.1.0.
Now I'm can't get either to configure:
% cabal unpack base
Unpacking to base-3.0.3.2/
% cd base-3.0.3.2
% cabal haddock
cabal: Run the 'configure' command first.
% cabal configure
Resolving dependencies...
Configuring base-3.0.3.2...
cabal: At least the following dependencies are missing:
base >=4.0 && <4.3, syb ==0.1.*
% cd ..
%
% cabal unpack base-4.3.1.0
Unpacking to base-4.3.1.0/
% cd base-4.3.1.0
% cabal haddock
cabal: Run the 'configure' command first.
% cabal configure
Resolving dependencies...
Configuring base-4.3.1.0...
configure: WARNING: unrecognized options: --with-compiler, --with-gcc
checking for gcc... gcc
checking whether the C compiler works... yes
...
checking for library containing iconv... -liconv
checking for library containing locale_charset... none required
configure: creating ./config.status
config.status: error: cannot find input file: `base.buildinfo.in'
% cd ..
Also, I can't revert to base-3.0.3.2, because it depends on having
base version >=4.0 <4.3 (WTF?), and I can't install base-4.2.0.2 b/c it fails
b/c it can't find base.buildinfo.in.
% cabal --version
cabal-install version 0.10.2
using version 1.10.1.0 of the Cabal library
% cabal info base
* base (library)
Synopsis: Basic libraries (backwards-compatibility version)
Versions available: 3.0.3.1, 3.0.3.2, (4.0.0.0), (4.1.0.0), (4.2.0.0),
(4.2.0.1), (4.2.0.2), (4.3.0.0), (4.3.1.0)
Versions installed: (4.3.1.0)
Homepage: [ Not specified ]
Bug reports: http://hackage.haskell.org/trac/ghc/newticket?component=libraries/base
Description: This is a backwards-compatible version of the base package.
It depends on a later version of base, and was probably
supplied with your compiler when it was installed.
License: BSD3
Maintainer: libraries#haskell.org
Source repo: http://darcs.haskell.org/packages/base3-compat
Dependencies: base >=4.0 && <4.3, syb ==0.1.*
Documentation: /usr/local/share/doc/ghc/html/libraries/base-4.3.1.0
Cached: Yes
Modules:
...
%
What am I doing wrong and how can I fix it?
Nobody is meant to self-compile base. It's tied to a particular ghc installation, so you couldn't use any other base package if you built it. I'm not surprised that the base package doesn't build from hackage; most likely nobody ever tries to build it.
Anyway, I'd try checking out the ghc source. The base.buildinfo.in file will be in the base package repo. You could copy the file from the repo to your unpacked distribution, but it's probably better to just build from the checked-out source.
Just be sure to only install the docs and not the library.

Resources