0

I have installed postgresql in my ubuntu 14.04 with apt-get command..
postgresql 9.4
libpg 9.4.8

I want to add a user defined c function for dynamic loading.
I have my c file and sql function file ready as per specification but main problem is that c file contain header lines like..

    #include "postgres.h"
    #include <string.h>
    #include "fmgr.h"

i have my folder on Desktop but there is no postgers.h or fmgr.h file..
I dont know where to find source file on my system but i have downloaded whole source from git and added in same folder..
If i run compiling command it shows

postgres_ext.h:47:9: error: unknown type name 'PG_INT64_TYPE'<br>
 typedef PG_INT64_TYPE pg_int64;



i dont know where to start.. should i place my file in any postgres directory and then compile or downloading the source file is right option? What to do with the error..? Please help.. Many thanks in advance.

1 Answer 1

1

Use PGXS to compile your code as an extension by writing a simple Makefile.

This will set up the include path, library path, etc for you and supply the correct compiler flags.

It's discussed in the same documentation as the tutorials that cover writing basic C functions.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks for your answer sir.. tried the same.. got following error.. /usr/src/postgres-master/src/include/postgres_ext.h:47:9: error: unknown type name ‘PG_INT64_TYPE’
/usr/src/postgres-master/src/include/c.h:66:72: fatal error: pg_config_os.h: No such file or directory compilation terminated.
Without seeing what exactly you did and how you installed, hard to say what's going on. At a wild guess you need to install the postgresql devel package for your OS/distro.
After lot of configuration i'm able to generate .so file.. my .so file is pgafis.so.. uploaded file in lib directory and uploaded .control and .sql and unpacked.sql file in appropriate directory.. when i run CREATE EXTENSION pgafis in my pgadmin-III i receive.. ERROR: could not load library "/usr/lib/postgresql/9.4/lib/pgafis.so": /usr/lib/postgresql/9.4/lib/pgafis.so: undefined symbol: lfsparms_V2 SQL state: XX000 Can u please help?
New question please. Link back to this for context.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.