Stack can't find libgfortran-3.dll when trying to build with hmatrix - haskell

I am trying to setup hmatrix on my Windows 10 machine with GHC 8.0.2.
I was following the answer here but when I try to build it says that it cannot find libgfortran-3.dll although I am sure I added it to the bin folder in the BLAS directory.
My code is in here
I run stack build and this is what I get:
hmatrix-0.18.0.0: configure
Progress: 1/2
-- While building package hmatrix-0.18.0.0 using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.0.2.exe --builddir=.stack-work\dist\ca59d0ab configure "--with-ghc=C:\\Program Files\\Haskell Platform\\8.0.2\\bin\\ghc.EXE" "--with-ghc-pkg=C:\\Program Files\\Haskell Platform\\8.0.2\\bin\\ghc-pkg.EXE" --user --package-db=clear --package-db=global --package-db=C:\sr\snapshots\b201cfe6\pkgdb --package-db=D:\Haskell\networks\.stack-work\install\65995373\pkgdb --libdir=D:\Haskell\networks\.stack-work\install\65995373\lib --bindir=D:\Haskell\networks\.stack-work\install\65995373\bin --datadir=D:\Haskell\networks\.stack-work\install\65995373\share --libexecdir=D:\Haskell\networks\.stack-work\install\65995373\libexec --sysconfdir=D:\Haskell\networks\.stack-work\install\65995373\etc --docdir=D:\Haskell\networks\.stack-work\install\65995373\doc\hmatrix-0.18.0.0 --htmldir=D:\Haskell\networks\.stack-work\install\65995373\doc\hmatrix-0.18.0.0 --haddockdir=D:\Haskell\networks\.stack-work\install\65995373\doc\hmatrix-0.18.0.0 --dependency=array=array-0.5.1.1 --dependency=base=base-4.9.1.0 --dependency=binary=binary-0.8.3.0 --dependency=bytestring=bytestring-0.10.8.1 --dependency=deepseq=deepseq-1.4.2.0 --dependency=random=random-1.1-9tceXaeYIMZ4JrKq20Egog --dependency=split=split-0.2.3.1-FWyXC6nhV0H3AfM8IzrEFk --dependency=storable-complex=storable-complex-0.2.2-G9QzpmZTKvgKKVagrcRWdL --dependency=vector=vector-0.11.0.0-HhutbadagxHIONIkSRJEug -fopenblas --extra-include-dirs=C:\OpenBLAS-v0.2.19-Win64-int32\include --extra-include-dirs=C:\Users\Yotam\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include --extra-lib-dirs=C:\OpenBLAS-v0.2.19-Win64-int32\bin --extra-lib-dirs=C:\Users\Yotam\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\lib
Process exited with code: ExitFailure 1
Logs have been written to: D:\Haskell\networks\.stack-work\logs\hmatrix-0.18.0.0.log
Configuring hmatrix-0.18.0.0...
Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.0.2.exe: Missing dependency on a foreign
library:
* Missing C library: libgfortran-3
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.
D:\OpenBLAS-v0.2.19-Win64-int32\bin includes both libopenblas.dll and libgfortran-3.dll and the blas directory was taken from this url
Thanks for any help

I've managed to install it as follows.
In yourpath\to\stack\x86_64-windows\msys2-20150512, open a msys2 shell by double-clicking on msys2_shell.bat.
In the shell, type:
pacman -S mingw-w64-x86_64-toolchain
Then add these "extra" in stack.yaml:
extra-include-dirs:
- yourpath\to\OpenBLAS\include
extra-lib-dirs:
- yourpath\to\OpenBLAS\lib
- yourpath\to\stack\x86_64-windows\msys2-20150512\usr\lib\gcc\x86_64-pc-msys\6.3.0
- yourpath\to\stack\x86_64-windows\msys2-20150512\mingw64\bin

Related

Missing C library error during stack build with nix

In my project I'm using a library that depends on two C packages: sqlite3 and libsqlite3-dev. I installed them using apt-get install and then build the project with stack build and everything works fine.
However, the stack build fails when used with nix with error message "* Missing C library: sqlite3". I understand that the nix enviroment is isolated and that I have to install it there. I tried installing it using nix-env -i sqlite3 but it returns error: selector ‘sqlite3’ matches no derivations. It looks it is missing in the channel (using nixpkgs-unstable).
Is there any way how use to use C libraries with stack and nix that are missing in the channel?
I am using nix because of a bug in IHaskell, otherwise I would be fine with just stack.
You need to add sqlite to your packages section in stack.yaml as follows:
nix:
enable: false
packages:
- sqlite
The enable: false is there so that Stack doesn't try to build with Nix by default. If you want this behaviour, remove that line.
There's an example of this here.

'cabal copy' failed during `stack build` in cifs directory

I'm following these instructions. I successfully did stack new and stack setup but stack build fails.
I found a git issue that this may be due to extra files listed in the cabal file, but removing them didn't fix the issue (and I'm just using the new-template without any changes). I am on Ubuntu 14.04 and installed stack using the script. Is there anything else I can look into?
It appears that this might be due to me trying to build inside of a cifs directory. Is there anything I can do to handle this?
# stack build
ehri-haskell-0.1.0.0: configure (lib + exe)
Configuring ehri-haskell-0.1.0.0...
ehri-haskell-0.1.0.0: build (lib + exe)
Preprocessing library ehri-haskell-0.1.0.0...
Preprocessing executable 'ehri-haskell-exe' for ehri-haskell-0.1.0.0...
ehri-haskell-0.1.0.0: copy/register
Installing library in
/mnt/docs/RubymineProjects/ehri-haskell/.stack-work/install/x86_64-linux/lts-8.6/8.0.2/lib/x86_64-linux-ghc-8.0.2/ehri-haskell-0.1.0.0-Kh3VLZPfbij7EgcL22QBMN
Installing executable(s) in
/mnt/docs/RubymineProjects/ehri-haskell/.stack-work/install/x86_64-linux/lts-8.6/8.0.2/bin
/mnt/docs/RubymineProjects/ehri-haskell/.stack-work/install/x86_64-linux/lts-8.6/8.0.2/bin/.copyFile5965166491189641421.tmp:
copyFile: does not exist (Host is down)
'cabal copy' failed. Error message:
-- While building package ehri-haskell-0.1.0.0 using:
/root/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.2.0 copy
Process exited with code: ExitFailure 1
One possible cause of this issue is:
* No module named "Main". The 'main-is' source file should usually have a header indicating that it's a 'Main' module.
# stack --version
Version 1.4.0, Git revision e714f1dd3fade19496d91bd6a017e435a96a6bcd (4640 commits) x86_64 hpack-0.17.0
Looks like the issue is caused by the depth of the folder where the project lives (Windows 10, x64). From the moment the depth exceeds some threshold, described error appears. So try moving the project folder up in directories tree.

Error installing the shuffle library with stack

Using stack 1.2.0 and LTS 7.0 I'm getting the following error installing the shuffle library:
$ cabal get shuffle
$ cd shuffle-0.1.3.3
$ stack build
...
/tmp/shuffle-0.1.3.3/Setup.hs:2:1: error:
Failed to load interface for ‘Distribution.Simple.UUAGC’
Perhaps you meant
Distribution.Simple.UHC (from Cabal-1.24.0.0)
Distribution.Simple.GHC (from Cabal-1.24.0.0)
Distribution.Simple.JHC (from Cabal-1.24.0.0)
Use -v to see a list of the files searched for.
/tmp/shuffle-0.1.3.3/Setup.hs:3:1: error:
Failed to load interface for ‘UU.UUAGC’
Use -v to see a list of the files searched for.
-- While building package shuffle-0.1.3.3 using:
/usr/local/bin/ghc --make -odir /tmp/shuffle-0.1.3.3/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/setup -hidir /tmp/shuffle-0.1.3.3/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/setup -i -i. -package=Cabal-1.24.0.0 -clear-package-db -global-package-db -package-db=/home/asr/.stack/snapshots/x86_64-linux/lts-7.0/8.0.1/pkgdb /tmp/shuffle-0.1.3.3/Setup.hs -o /tmp/shuffle-0.1.3.3/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/setup/setup
Process exited with code: ExitFailure 1
I'm using the following stack.yaml file:
resolver: lts-7.0
# Local packages, usually specified by relative directory name
packages:
- '.'
extra-deps:
- logict-state-0.1.0.2
- pqueue-1.3.1.1
- uhc-util-0.1.6.6
- uuagc-0.9.52.1
- uuagc-cabal-1.0.6.0
- uulib-0.9.22
Do I need to add/change something in the library or in stack.yaml? (I had no problems using cabal-install).
I was able to get this to work by adding the following to stack.yaml:
explicit-setup-deps:
shuffle: true
For more information, see: https://docs.haskellstack.org/en/stable/yaml_configuration/#explicit-setup-deps
It appears that this package requires you to have installed uuagc-cabal to build it. Starting after Cabal-1.23 these kinds of package dependencies for Setup.hs files can be captured in the custom-setup section of a cabal file.
There are tickets about this functionality for stack that seem to be interlinked from here:
Setup.hs cannot use local snapshot dependencies WAS stack failing to resolve local dependencies of multiple package project #897

stack install: Setup.hs: does not exist

I put stack.exe v0.1.2.2 in one of my PATH dirs, then install ghc-7.8.4 via stack setup.
I trying to install ghc-mod and obtain strange error Setup.hs: does not exist:
stack install ghc-mod
Using resolver: lts-2.21 from global config file: C:\Users\martynov_p\AppData\Roaming\stack\global\stack.yaml
ghc-paths-0.1.0.9: configure
data-default-class-0.0.1: configure
dlist-0.7.1.1: configure
ansi-terminal-0.6.2.1: configure
hscolour-1.22: configure
extra-1.1: configure
mtl-2.1.3.1: configure
cmdargs-0.10.13: configure
Progress: 8/54
-- While building package cmdargs-0.10.13 using:
C:\\Users\\martynov_p\\appdata\\Local\\Programs\\stack\\x86_64-windows\\ghc-7.8.4\\bin\\runhaskell.exe -package=Cabal-1.18.1.5 -clear-package-db -global-package-db -package-db=C:\Users\martynov_p\AppData\Roaming\stack\snapshots\x86_64-windows\lts-2.21\7.8.4\pkgdb\ C:\Users\MARTYN~1\AppData\Local\Temp\stack12088\Setup.hs --builddir=.stack-work\dist\x86_64-windows\Cabal-1.18.1.5\ configure --user --package-db=clear --package-db=global --package-db=C:\Users\martynov_p\AppData\Roaming\stack\snapshots\x86_64-windows\lts-2.21\7.8.4\pkgdb\ --constraint=base==4.7.0.2 --constraint=filepath==1.3.0.2 --constraint=process==1.2.0.0 --constraint=template-haskell==2.9.0.0 --constraint=transformers==0.3.0.0 --libdir=C:\Users\martynov_p\AppData\Roaming\stack\snapshots\x86_64-windows\lts-2.21\7.8.4\lib --bindir=C:\Users\martynov_p\AppData\Roaming\stack\snapshots\x86_64-windows\lts-2.21\7.8.4\bin --datadir=C:\Users\martynov_p\AppData\Roaming\stack\snapshots\x86_64-windows\lts-2.21\7.8.4\share --docdir=C:\Users\martynov_p\AppData\Roaming\stack\snapshots\x86_64-windows\lts-2.21\7.8.4\doc\cmdargs-0.10.13 --htmldir=C:\Users\martynov_p\AppData\Roaming\stack\snapshots\x86_64-windows\lts-2.21\7.8.4\doc\cmdargs-0.10.13 --haddockdir=C:\Users\martynov_p\AppData\Roaming\stack\snapshots\x86_64-windows\lts-2.21\7.8.4\doc\cmdargs-0.10.13
Process exited with code: ExitFailure 1
Logs have been written to: "C:\\Users\\martynov_p\\AppData\\Roaming\\stack\\global\\.stack-work\\logs\\cmdargs-0.10.13.log"
Configuring cmdargs-0.10.13...
Setup.hs: does not exist
This is probably due to a bug in cabal, and is resolved by upgrading your cabal version or switching to a newer stackage resolver. See
https://github.com/haskell/cabal/issues/1733
https://github.com/commercialhaskell/stack/issues/943

Cannot install accelerate-cuda in Haskell

I am on a linux box and trying to experiment with Haskell's Accelerate library but having problems installing it. I have successfully installed the accelerate package but there seems to be a dependency problem, which I have detailed below.
cabal: Error: some packages failed to install:
accelerate-cuda-0.14.0.0 depends on haskell-src-exts-1.14.0.1 which failed to
install.
cuda-0.5.1.1 failed during the configure step. The exception was:
ExitFailure 1
haskell-src-exts-1.14.0.1 failed during the configure step. The exception was:
ExitFailure 1
haskell-src-meta-0.6.0.5 depends on haskell-src-exts-1.14.0.1 which failed to
install.
language-c-quote-0.7.6 depends on haskell-src-exts-1.14.0.1 which failed to
install.
I searched SO and noticed someone else had a similiar issue installed the cuda package, and was resolved by adding the cabal bin path to the PATH; I tried this but it didn't solve this problem.
Please could someone help as I really keen to play with this fantastic library.
I wanted to check accelerate-examples and play with them and I also didn't have CUDA GPU (AMD only) and that's how I eventually installed accelerate-examples with stack:
git clone https://github.com/AccelerateHS/accelerate-examples
cd accelerate-examples
#choose version:
ln stack-8.6.yaml stack.yaml
#build without CUDA targeting:
stack build --flag accelerate-examples:-llvm-ptx --flag accelerate-fft:-llvm-ptx
Installation will build all the examples and print the info regarding where they was put.
Might also need to specify GHC libs path with something like: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.stack/programs/x86_64-linux/ghc-8.6.5/lib/ghc-8.6.5/rts/
Also checked that accelerate installs as well the same way but even without specifying any flags (I guess because it doesn't build any programs yet?), but examples are what's fun :)
P.S. You can move llvm-ptx flags to stack.yaml config: change # flags: {} line to:
flags:
accelerate-fft:
llvm-ptx: false
accelerate-examples:
llvm-ptx: false

Resources