skip to Main Content

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


  1. 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:

    cc -fpic -I /location/of/postgres/include -c example.c
    

    To find that location, you can use pg_config:

    pg_config --includedir
    

    There is a similar --libdir option to show the library path for when you link the executable.

    Login or Signup to reply.
  2. for ubuntu: apt-get -y install postgresql-server-dev-13 after apt-get -y install postgresql-13

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search