Solved the problem by downgrading to postgreSQL 16.4. After installing version 16.4 I followed through docs tutorial 'libpq-build' and my app linked without any 'undefined reference' or 'undefined symbol' errors with linker commands presented in the docs.