Skip site navigation (1) Skip section navigation (2)

Re: Compiling a static libpq

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Julia Jacobson <julia(dot)jacobson(at)arcor(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Compiling a static libpq
Date: 2011-04-04 16:08:38
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On Sun, Apr 3, 2011 at 1:07 PM, Julia Jacobson <julia(dot)jacobson(at)arcor(dot)de> wrote:
> After having done extensive web search and not found anybody to solve the
> problem of interest on the general PostgreSQL mailing list, in the
> PostgreSQL newsgroup on usenet or on the PostgreSQL IRC channel, I would
> like to ask you how to compile a static libpq working without a dynamic
> libpq.
> So far, I've compiled libpq (from PostgreSQL version 8.4.6, 8.4.7 and 9.0.3)
> on my own under Linux (Ubuntu 10.4), Mac OS X 10.4 and Windows 7 using GCC.
> Indeed, I always succeeded in producing libpq.a, but linking this library to
> a minimal application resulted in a program which only ran with libpq.dylib
> (libpq.dll or - depending on the platform) being present and not
> without it.
> It seems like the libpq.a produced by compiling PostgreSQL with
> "./configure" and "make" still imports the dynamic libpq.
> Is there a way to get rid of the dependence on the dynamic libpq library in
> PostgreSQL client applications?

I was able to compile and run the testlibpq.c example on Fedora 12.  I
deleted the entire installation tree after compiling it, so there was
no dynamic libpq to be found.

gcc -I$HOME/project/include -L$HOME/project/lib testlibpq.c -o
testlibpq -static -lpq -lpthread

It might help to troubleshoot if you could provide more details on
exactly what you did, including the compiler invocation.

Robert Haas
The Enterprise PostgreSQL Company

In response to

pgsql-hackers by date

Next:From: Robert HaasDate: 2011-04-04 16:13:12
Subject: Re: time table for beta1
Previous:From: Dave PageDate: 2011-04-04 16:01:32
Subject: Re: time table for beta1

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group