How to fix 'postgres.h' file not found problem?

Jasper Zhou picture Jasper Zhou · Jun 23, 2019 · Viewed 7.9k times · Source

I am trying to write a base type for PostgreSQL in C (using xcode), and I already installed PostgreSQL 11, but it seems that postgres.h cannot be simply included in the file ("'postgres.h' file not found").

Could someone tell me how to fix that problem? And can I write code under an arbitary directory, or do I have to write under the PostgreSQL directory?

Or perhaps the question should be: how to install header files like postgres.h?

Answer

Nuzhat Ansari picture Nuzhat Ansari · May 18, 2020

Install postgresql-server-dev package with this command:

sudo apt install postgresql-server-dev-XX

Replace [XX] with your already installed version of postgresql:9.5, 10, 11, 12