I’m trying to create my own function (using C) in postgres for which I’m referring this doc: http://www.linuxgazette.cz/139/peterson.html
For compiling – I’m referring: Section 33.9.6 . But, when I run below command:
cc -fpic -c example.c
I get this error:
example.c:1:22: fatal error: postgres.h: No such file or directory
#include "postgres.h"
^
compilation terminated.
I have also installed postgresql-server-dev-all package and tried with the solution provided in this link: How to fix 'postgres.h' file not found problem?
Nothing working for me. Please let me know how I can have postgres.h file.
I’m using postgres-12 on centos -7.
2
Answers
First: If you didn’t install PostgreSQL from source, make sure that you installed the headers, which are in the
-devel
package.If the problem persists even with the headers installed, the reason is that you forgot to tell the compiler where to look for header files:
To find that location, you can use
pg_config
:There is a similar
--libdir
option to show the library path for when you link the executable.for ubuntu:
apt-get -y install postgresql-server-dev-13
afterapt-get -y install postgresql-13