Re: How to add and use a static library within Postgres backend

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: XiaoChuan Yu <xcyu(dot)se(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: How to add and use a static library within Postgres backend
Date: 2015-11-29 13:48:51
Message-ID: CAMsr+YGCVguU11f56_8Vejv620ZnMV=BQh0XJwhGyw8j32EYrg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 27 November 2015 at 10:35, XiaoChuan Yu <xcyu(dot)se(at)gmail(dot)com> wrote:

> I'm doing some experimenting with the storage engine and I'd like to use a
> C++ static library (that has C headers). I only need this to build on
> Ubuntu 64-bit for now.
> How do I make postgres build with this library?
>

Build it separately. Link to it like any other library. Take a look at
configure.in for how libraries are discovered and the Makefile.am files for
how the header path and linker flags are defined.

What changes do I need to make to the build system files?
>

As above. Look at how PostgreSQL uses existing libraries. If the library
presents a pure C interface it should be just like everything else.

> I assume headers go in src/include but where do I put the library.a file?
>

Don't copy anything into PostgreSQL's source tree. Add new linker path and
include path entries so the build system knows how to find the files where
you originally compiled them.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2015-11-29 14:33:31 Re: silent data loss with ext4 / all current versions
Previous Message Craig Ringer 2015-11-29 13:41:26 Re: silent data loss with ext4 / all current versions