How to add and use a static library within Postgres backend

Started by XiaoChuan Yuabout 10 years ago2 messages
#1XiaoChuan Yu
xcyu.se@gmail.com

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?
What changes do I need to make to the build system files?
I assume headers go in src/include but where do I put the library.a file?

Thanks,
Xiaochuan Yu

#2Craig Ringer
craig@2ndquadrant.com
In reply to: XiaoChuan Yu (#1)
Re: How to add and use a static library within Postgres backend

On 27 November 2015 at 10:35, XiaoChuan Yu <xcyu.se@gmail.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