/usr/bin/ld: cannot find -lpq
I have just migrated form windows to ubuntu. and I am trying to download diesel_cli for rust. After fetching all crates in last it gives an error that /usr/bin/ld: cannot find -lpq.
The ld
command is telling you that it could not find the pq
library. man ld
will tell you about:
-l namespec
--library=namespec
Add the archive or object file specified by namespec to the list of files to link.
This option may be used any number of times. If namespec is of the form :filename, ld
will search the library path for a file called filename, otherwise it will search the
library path for a file called libnamespec.a.
On systems which support shared libraries, ld may also search for files other than
libnamespec.a. Specifically, on ELF and SunOS systems, ld will search a directory for
a library called libnamespec.so before searching for one called libnamespec.a. (By
convention, a ".so" extension indicates a shared library.) Note that this behavior
does not apply to :filename, which always specifies a file called filename.
This tells us that the actual file you need is called libpq.so
orlibpq.a
.
You should see if your rust/diesel_cli
environment has libpq.so
.
Asking the packaging system about libpq
, one sees:
$ apt-cache search libpq
libpq-dev - header files for libpq5 (PostgreSQL library)
libpq5 - PostgreSQL C client library
cl-pg - Common Lisp library that provides a socket level postgresql interface
golang-github-lib-pq-dev - pure Go postgres driver for Go’s database/sql package
libghc-postgresql-libpq-dev - low-level binding to libpq
libghc-postgresql-libpq-doc - low-level binding to libpq; documentation
libghc-postgresql-libpq-prof - low-level binding to libpq; profiling libraries
libpgtcl - Tcl client library binding for PostgreSQL
libpgtcl-dev - Tcl client library binding for PostgreSQL - development files
libpostgresql-ocaml - OCaml bindings to PostgreSQL's libpq (runtime)
libpostgresql-ocaml-dev - OCaml bindings to PostgreSQL's libpq
libpqtypes-dev - parameterized queries libpq extension - development
libpqtypes0 - parameterized queries libpq extension - shared library
libpqtypes0-dbg - parameterized queries libpq extension - debug symbols
libpqxx-3.1 - C++ library to connect to PostgreSQL
libpqxx-3.1-dbg - C++ library to connect to PostgreSQL (debugging symbols)
libpqxx-4.0 - C++ library to connect to PostgreSQL
libpqxx-dbg - C++ library to connect to PostgreSQL (debugging symbols)
libpqxx-dev - C++ library to connect to PostgreSQL (development files)
libpqxx-doc - C++ library to connect to PostgreSQL (documentation)
libpqxx3-dev - C++ library to connect to PostgreSQL (development files)
libpqxx3-doc - C++ library to connect to PostgreSQL (documentation)
python-pg8000 - Pure-Python PostgreSQL Driver
ruby-pg - PostgreSQL interface for Ruby
Check the rust/diesel_cli
documentation for requirements for postgresql
?
I'll let you do the apt-cache search postgresql
yourself, rather than adding 452 lines to this post.