1. Use PGXN to install pg_repack on postgres 9.6 on top of Ubuntu 14.04
  2. https://askubuntu.com/questions/617751/default-location-of-postgresql-when-installing-through-apt-get
  3. https://reorg.github.io/pg_repack/#installation

I also want to install pg_repack. I finished the following two command.
sudo apt-get install postgresql-server-dev-all
sudo apt-get install postgresql-common

sudo apt-get install pgxnclient successful.

sudo su PATH=/usr/lib/postgresql/14/bin:$PATH successful.
pgxn install pg_repack then error occurred.

/usr/bin/ld: cannot find -llz4
/usr/bin/ld: cannot find -lreadline
collect2: error: ld returned 1 exit status
make[1]: *** [/usr/lib/postgresql/14/lib/pgxs/src/makefiles/pgxs.mk:475: pg_repack] Error 1
make[1]: Leaving directory '/tmp/tmpxh8zkbcg/pg_repack-1.4.7/bin'
make: *** [Makefile:35: all] Error 2
ERROR: command returned 2: make PG_CONFIG=/usr/lib/postgresql/14/bin/pg_config all

2 Answers 2


I think compiler not found 2 libraries:

  • /usr/bin/ld: cannot find -llz4
  • /usr/bin/ld: cannot find -lreadline

you need to install them. I had similar problem with my alpine docker container. I fixed this by installing missing libraries lz4-dev, gawk:

#apk add lz4-dev

#apk add gawk

after that extension pg_repack was built successfully. As example https://github.com/Raul-dev/Migration-MSSQL-toPostgres/blob/main/source/Dockerfile


Usually pg_repack is installed from the repository rather than from sources.

Check your OS repositories, typically the package is named:

  • postgresql-15-repack - Debian family/Ubuntu
  • pg_repack15 - Red Hat family/CentoS/Rocky

Where 15 is the major version of the postgresql for which the extension is built.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.