haskell-numerics / hmatrix

Linear algebra and numerical computation
381 stars 104 forks source link

Runtime error: can't load .so/.DLL #314

Closed jondeaton closed 4 years ago

jondeaton commented 4 years ago

Hi im using macOS Catalina 10.15.1 with GHCi, version 8.0.2 and installed hmatrix-0.20.0.0 with

cabal install hmatrix

but when I do

> import Numeric.LinearAlgebra.Data 
> vector [1..3]

I get

can't load .so/.DLL for: /Users/jonpdeaton/Library/Haskell/ghc-8.0.2-x86_64/lib/x86_64-osx-ghc-8.0.2/libHSstorable-complex-0.2.3.0-72DFYkSDnVABWi9vl7ksxh-ghc8.0.2.dylib (dlopen(/Users/jonpdeaton/Library/Haskell/ghc-8.0.2-x86_64/lib/x86_64-osx-ghc-8.0.2/libHSstorable-complex-0.2.3.0-72DFYkSDnVABWi9vl7ksxh-ghc8.0.2.dylib, 5): REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB has segment 2 which is not a writable segment (__LINKEDIT) in /Users/jonpdeaton/Library/Haskell/ghc-8.0.2-x86_64/lib/x86_64-osx-ghc-8.0.2/libHSstorable-complex-0.2.3.0-72DFYkSDnVABWi9vl7ksxh-ghc8.0.2.dylib)

I would appreciate any help trying to use hmatrix.

idontgetoutmuch commented 4 years ago

I have not been brave enough to upgrade to Catalina. cabal install hmatrix works for me on High Sierra but I believe this way of working is now discouraged.

I also tried nix:

{ nixpkgs ? import <nixpkgs> {}, compiler ? "default", doBenchmark ? false }:

let

  inherit (nixpkgs) pkgs;

  f = { mkDerivation, base, hmatrix, hmatrix-gsl
      , pretty, stdenv
      }:
      mkDerivation {
        pname = "examples";
        version = "0.19.0.0";
        src = ./.;
        isLibrary = false;
        isExecutable = true;
        executableHaskellDepends = [
          base hmatrix
        ];
        homepage = "https://github.com/albertoruiz/hmatrix";
        description = "Example usage of the various hmatrix packages";
        license = stdenv.lib.licenses.bsd3;
      };

  haskellPackages = if compiler == "default"
                       then pkgs.haskellPackages
                       else pkgs.haskell.packages.${compiler};

  variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id;

  drv = variant (haskellPackages.callPackage f {});

in

  if pkgs.lib.inNixShell then drv.env else drv
nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz
ghci
Prelude>import Numeric.LinearAlgebra.Data 
Prelude Numeric.LinearAlgebra.Data> vector [1..3]
[1.0,2.0,3.0]

I notice you are using quite an old ghc: 8.0.2. How did you install ghc?

idontgetoutmuch commented 4 years ago

I should have added that I have asked a colleague with Catalina to try using the above nix route.

jondeaton commented 4 years ago

Thanks for the help. I'm not familiar with nix, so I'll have to look into trying to apply that solution... I installed ghc/ghci with

brew install ghc
brew install ghci

When I do that it actually says that I have ghc version 8.8.1, but when I start ghci for some reason it says version 8.0.1. Is this the recommended way of installing these?

jondeaton commented 4 years ago

I got it to work finally.... Instead of installing cabal with brew install cabal I used the Haskell Platform to install cabal, and then had to do

cabal user-config update
cabal install hmatrix --lib

In order to get it to work.

idontgetoutmuch commented 4 years ago

Great that it's working :) but I am pretty sure you are advised these days to create something like a .cabal file for your project and use cabal-new or stack. I have the impression that both the latter now give some of the benefits of nix (without the big learning curve).