尝试在 Nixos 上使用堆栈编译静态可执行文件时出现链接器错误
Linker errors when trying to compile static executable with stack on Nixos
看来我可能需要向 nix 依赖项添加一些 'packages',尽管我不确定如何确定哪些包(除了对每个 lm
、lrt
...)?
stack install
Building all executables for `sodiumSierraStrawberry' once. After a successful build of all of them, only specified executables will be rebuilt.
sodiumSierraStrawberry-0.1.0.0: configure (exe)
Configuring sodiumSierraStrawberry-0.1.0.0...
sodiumSierraStrawberry-0.1.0.0: build (exe)
Preprocessing executable 'sodiumSierraStrawberry' for sodiumSierraStrawberry-0.1.0.0..
Building executable 'sodiumSierraStrawberry' for sodiumSierraStrawberry-0.1.0.0..
[1 of 2] Compiling Paths_sodiumSierraStrawberry ( .stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/sodiumSierraStrawberry/autogen/Paths_sodiumSierraStrawberry.hs, .stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/sodiumSierraStrawberry/sodiumSierraStrawberry-tmp/Paths_sodiumSierraStrawberry.o )
[2 of 2] Compiling Prompt ( src/Prompt.hs, .stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/sodiumSierraStrawberry/sodiumSierraStrawberry-tmp/Prompt.o )
Linking .stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/sodiumSierraStrawberry/sodiumSierraStrawberry ...
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lm
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lrt
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lutil
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -ldl
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lgmp
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lm
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lrt
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -ldl
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lpthread
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)
-- While building package sodiumSierraStrawberry-0.1.0.0 using:
/home/chris/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.3 --builddir=.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1 build exe:sodiumSierraStrawberry --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
阴谋集团文件:
-- This file has been generated from package.static.yaml by hpack version 0.28.2.
--
-- see: https://github.com/sol/hpack
--
-- hash: dc5d80120403b39adcd93487e3eb7b084fcc8abb48bc9c23eaaa9dbc7c48cb06
cabal-version: >= 1.10
name: sodiumSierraStrawberry
version: 0.1.0.0
author: Chris Stryczynski
maintainer: Chris Stryczynski
license: BSD3
license-file: LICENSE
build-type: Simple
extra-source-files:
ChangeLog.md
executable sodiumSierraStrawberry
main-is: Prompt.hs
other-modules:
Paths_sodiumSierraStrawberry
hs-source-dirs:
src
default-extensions: LambdaCase
ghc-options: -Wall -O2 -static -threaded -main-is Prompt
cc-options: -static
ld-options: -static -pthread
build-depends:
MissingH
, aeson
, base
, bytestring
, directory
, filepath
, optparse-applicative
, pretty-simple
, safe
, split
, stm
, string-conversions
, text
, thyme
, time
default-language: Haskell2010
在这种特殊情况下,我能够通过添加解决它:
nix:
packages:
- glibc.static
- gmp5.static
但是,我仍然不确定如何确定这些 flags
(lm、lrt 等)与实际包裹之间的关系。
看来我可能需要向 nix 依赖项添加一些 'packages',尽管我不确定如何确定哪些包(除了对每个 lm
、lrt
...)?
stack install
Building all executables for `sodiumSierraStrawberry' once. After a successful build of all of them, only specified executables will be rebuilt.
sodiumSierraStrawberry-0.1.0.0: configure (exe)
Configuring sodiumSierraStrawberry-0.1.0.0...
sodiumSierraStrawberry-0.1.0.0: build (exe)
Preprocessing executable 'sodiumSierraStrawberry' for sodiumSierraStrawberry-0.1.0.0..
Building executable 'sodiumSierraStrawberry' for sodiumSierraStrawberry-0.1.0.0..
[1 of 2] Compiling Paths_sodiumSierraStrawberry ( .stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/sodiumSierraStrawberry/autogen/Paths_sodiumSierraStrawberry.hs, .stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/sodiumSierraStrawberry/sodiumSierraStrawberry-tmp/Paths_sodiumSierraStrawberry.o )
[2 of 2] Compiling Prompt ( src/Prompt.hs, .stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/sodiumSierraStrawberry/sodiumSierraStrawberry-tmp/Prompt.o )
Linking .stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/sodiumSierraStrawberry/sodiumSierraStrawberry ...
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lm
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lrt
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lutil
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -ldl
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lgmp
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lm
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lrt
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -ldl
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lpthread
/nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)
-- While building package sodiumSierraStrawberry-0.1.0.0 using:
/home/chris/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.3 --builddir=.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1 build exe:sodiumSierraStrawberry --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
阴谋集团文件:
-- This file has been generated from package.static.yaml by hpack version 0.28.2.
--
-- see: https://github.com/sol/hpack
--
-- hash: dc5d80120403b39adcd93487e3eb7b084fcc8abb48bc9c23eaaa9dbc7c48cb06
cabal-version: >= 1.10
name: sodiumSierraStrawberry
version: 0.1.0.0
author: Chris Stryczynski
maintainer: Chris Stryczynski
license: BSD3
license-file: LICENSE
build-type: Simple
extra-source-files:
ChangeLog.md
executable sodiumSierraStrawberry
main-is: Prompt.hs
other-modules:
Paths_sodiumSierraStrawberry
hs-source-dirs:
src
default-extensions: LambdaCase
ghc-options: -Wall -O2 -static -threaded -main-is Prompt
cc-options: -static
ld-options: -static -pthread
build-depends:
MissingH
, aeson
, base
, bytestring
, directory
, filepath
, optparse-applicative
, pretty-simple
, safe
, split
, stm
, string-conversions
, text
, thyme
, time
default-language: Haskell2010
在这种特殊情况下,我能够通过添加解决它:
nix:
packages:
- glibc.static
- gmp5.static
但是,我仍然不确定如何确定这些 flags
(lm、lrt 等)与实际包裹之间的关系。