Here is a compilation of the various -dev library packages needed for gnuplot in ubuntu. Package names must be the same as in Debian, and in other Debian based distributions such as Mint. Additional -dev packages that are installed automatically with named packages are not listed or indicated in (parentheses).
Use an external libreadline instead of the built-in gnuplot replacement (recommended)
libreadline-dev
Have the math functions provided by the cerf library (cannot harm)
libcerf-dev
For the old interactive terminal x11
libx11-dev
For pdfcairo , pngcairo , epscairo
libcairo2-dev libpango1-dev
optionally for the wxt interactive terminal (try ./configure --with-wx-single-threaded in case of problems (for example, make check crash). If it does not compile with complaints about "XInitThreads", try TERMLIBS="-lX11"./configure .)
libwxgtk2.8-dev or libwxgtk3.0-dev libgtk2.0-dev
For raster terminals based on libgd png , gif , jpeg
libgd-dev (libxpm-dev) (libjpeg-turbo8-dev) (libtiff5-dev)
For qt interactive terminal ( ./configure --with-qt=qt5 )
qtbase5-dev libqt5svg5-dev qttools5-dev-tools # on Linux Mint (as per comment by Allan below)
alternatively for qt4 ( ./configure --with-qt=qt4 )
libqt4-dev
For lua terminal
liblua5.2-dev (also read ./INSTALL)
For caca terminal in text mode ( ./configure --with-caca )
libcaca-dev
The list is not final (I do not have a spare system to check all the dependencies at the moment). Feel free to add, update and fix!