Reputation: 1547
I'm building Haskell foreign library using nix with cabal2nix. After build ./result/
directory contains libroman.so
under /lib/ghc-8.8.4/
subdirectory.
When trying to use it in another derivation (qt one in my case) it is not visible by the linker.
Haskell nix:
let
pkgs = import <nixpkgs> {};
in
pkgs.haskellPackages.callCabal2nix "roman" ./. {}
Qt nix:
let
pkgs = import <nixpkgs> {};
romanEngine = import ../engine/default.nix;
in
pkgs.qt5.mkDerivation {
name = "roman-gui";
src = ./.;
nativeBuildInputs = [
pkgs.qt5.qmake
];
buildInputs = [
pkgs.qt5.qtbase
romanEngine
];
}
Linker error:
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: cannot find -lroman
How can I link correctly to foreign library I have build?
Upvotes: 0
Views: 114
Reputation: 7369
This is untested, but might lead toward a solution.
stdenv
will configure the linker to look in <storepath>/lib
. Perhaps you could symlink your libs into there?
let
pkgs = import <nixpkgs> {};
inherit (pkgs.haskell.lib) overrideCabal;
generatedPkg = pkgs.haskellPackages.callCabal2nix "roman" ./. {};
in
overrideCabal generatedPkg (
drv: {
postInstall = (drv.postInstall or "") + ''
ln -s $out/lib/ghc-*/* $out/lib
# or something similar to make the libs available where the linker
# expects them
'';
}
)
Upvotes: 1