简体   繁体   中英

Why is there this dune build error? 'cannot find -lz'

I am trying to build a project with this dune file:

src/lib/precomputed_values/gen_values/dune :

(executable
 (name gen_values)
 (flags -w -32)
 (libraries
   ;; opam libraries
   stdio
   async_kernel
   compiler-libs
   core_kernel
   ppxlib
   ppxlib.ast
   ppxlib.astlib
   async
   core
   ocaml-migrate-parsetree
   base
   ocaml-compiler-libs.common
   async_unix
   base.caml
   sexplib0
   ;; local libraries
   coda_runtime_config
   consensus
   transaction_snark
   mina_state
   snark_params
   coda_genesis_proof
   blockchain_snark
   mina_base
   global_signer_private_key
   ppx_util
   snarky.backendless
   genesis_constants
   pickles
   test_genesis_ledger
   coda_genesis_ledger
   staged_ledger_diff
 )
 (preprocessor_deps ../../../config.mlh)
 (preprocess
  (pps ppx_version ppx_optcomp ppx_let ppxlib.metaquot ppx_here))
 (instrumentation (backend bisect_ppx))
 (modes native))

But am getting the error :

File "src/lib/precomputed_values/gen_values/dune", line 2, characters 7-17:
2 |  (name gen_values)
           ^^^^^^^^^^
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
File "caml_startup", line 1:
Error: Error during linking (exit code 1)
Makefile:84: recipe for target 'build' failed
make: *** [build] Error 1

Could anyone point me in the right direction? Thanks:)

Do you have the libz available on your system? it looks like the ld linker does not find it in its search path. libz.a is a C library that implements C function for compressing/decompressing data. Such libraries come with your OS distribution independently of Ocaml.

Ocaml tooling provides way to use C library (via stub) using ld (the standard linker) that will link your ocaml stubs to the functions of libz.a. But if the required library is missing, you get the error you quoted.

-lz is saying to ld to link your application with the libz.a (or libz.so ) library that is usually located in /usr/lib - if libz.a ( libz.so ) is not there, the linker will fail causing the emission of the following message:

/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM