pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Statically linking against libpq
3+ messages / 2 participants
[nested] [flat]

* Statically linking against libpq
@ 2016-07-06 20:01 Johnny Yan <jyan@tableau.com>
  2016-07-06 21:06 ` Re: Statically linking against libpq Heikki Linnakangas <hlinnaka@iki.fi>
  0 siblings, 1 reply; 3+ messages in thread

From: Johnny Yan @ 2016-07-06 20:01 UTC (permalink / raw)
  To: pgsql-odbc

Hi,

We're building the postgres odbc driver by ourselves for our customers on Linux. It builds against hence depends on libpq.so. We're wondering if there is a secret configure flag to statically link against libpq such that the final psqlodbcw.so has less dependencies and in particular doesn't depend on libpq.so. Also if there is no such config flag yet, are you guys planning to add one? Thank you for your help in advance.

Johnny

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Statically linking against libpq
  2016-07-06 20:01 Statically linking against libpq Johnny Yan <jyan@tableau.com>
@ 2016-07-06 21:06 ` Heikki Linnakangas <hlinnaka@iki.fi>
  2016-07-06 21:20   ` Re: Statically linking against libpq Johnny Yan <jyan@tableau.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Heikki Linnakangas @ 2016-07-06 21:06 UTC (permalink / raw)
  To: Johnny Yan <jyan@tableau.com>; pgsql-odbc

On 07/06/2016 11:01 PM, Johnny Yan wrote:
> Hi,
>
> We're building the postgres odbc driver by ourselves for our
> customers on Linux. It builds against hence depends on libpq.so.
> We're wondering if there is a secret configure flag to statically
> link against libpq such that the final psqlodbcw.so has less
> dependencies and in particular doesn't depend on libpq.so.

There's no such flag, currently.

One option is to create a temporary installation of libpq, with just the 
static library. The linker will use the static library, if it can't find 
a shared one. Something along the lines of:

mkdir static-libpq
mkdir static-libpq/lib
ln -s `pg_config --libdir`/libpq.a static-libpq/lib/libpq.a
ln -s `pg_config --includedir` static-libpq/include

./configure --with-libpq=static-libpq ...

Assuming your libpq is built with OpenSSL, though, you'll also need to 
pass LDFLAGS="-lssl -lcrypto" to make the configure test pass. The 
resulting ODBC driver will still need libssl and libcrypto as shared 
libraries, if built that way.

There might be a more straightforward way to do that, with suitable 
linked flags, but I don't know how.

> Also if there is no such config flag yet, are you guys planning to
> add one?

No such plans. If you want to write a patch, and it's not too 
complicated, I wouldn't mind adding it, thouhg.

- Heikki


-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Statically linking against libpq
  2016-07-06 20:01 Statically linking against libpq Johnny Yan <jyan@tableau.com>
  2016-07-06 21:06 ` Re: Statically linking against libpq Heikki Linnakangas <hlinnaka@iki.fi>
@ 2016-07-06 21:20   ` Johnny Yan <jyan@tableau.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Johnny Yan @ 2016-07-06 21:20 UTC (permalink / raw)
  To: Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-odbc

Cool. That's all I want to know for now. Thank you Heikki.

Johnny

-----Original Message-----
From: Heikki Linnakangas [mailto:hlinnaka@gmail.com] On Behalf Of Heikki Linnakangas
Sent: Wednesday, July 06, 2016 2:06 PM
To: Johnny Yan <jyan@tableau.com>; pgsql-odbc@postgresql.org
Subject: Re: [ODBC] Statically linking against libpq

On 07/06/2016 11:01 PM, Johnny Yan wrote:
> Hi,
>
> We're building the postgres odbc driver by ourselves for our customers 
> on Linux. It builds against hence depends on libpq.so.
> We're wondering if there is a secret configure flag to statically link 
> against libpq such that the final psqlodbcw.so has less dependencies 
> and in particular doesn't depend on libpq.so.

There's no such flag, currently.

One option is to create a temporary installation of libpq, with just the static library. The linker will use the static library, if it can't find a shared one. Something along the lines of:

mkdir static-libpq
mkdir static-libpq/lib
ln -s `pg_config --libdir`/libpq.a static-libpq/lib/libpq.a ln -s `pg_config --includedir` static-libpq/include

./configure --with-libpq=static-libpq ...

Assuming your libpq is built with OpenSSL, though, you'll also need to pass LDFLAGS="-lssl -lcrypto" to make the configure test pass. The resulting ODBC driver will still need libssl and libcrypto as shared libraries, if built that way.

There might be a more straightforward way to do that, with suitable linked flags, but I don't know how.

> Also if there is no such config flag yet, are you guys planning to add 
> one?

No such plans. If you want to write a patch, and it's not too complicated, I wouldn't mind adding it, thouhg.

- Heikki



-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2016-07-06 21:20 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-07-06 20:01 Statically linking against libpq Johnny Yan <jyan@tableau.com>
2016-07-06 21:06 ` Heikki Linnakangas <hlinnaka@iki.fi>
2016-07-06 21:20   ` Johnny Yan <jyan@tableau.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox