pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dmitry Igrishin <dmitigr@gmail.com>
Cc: Tal Glozman <glozmantal@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Linker errors while creating a PostgreSQL C extension function.
Date: Sun, 19 Aug 2018 10:54:32 -0400
Message-ID: <20033.1534690472@sss.pgh.pa.us> (raw)
In-Reply-To: <CAAfz9KMkXro2X+uPW6ojVo0NatrUL-vzqjDEY2MNbq5SWjHsRQ@mail.gmail.com>
References: <1534676183995-0.post@n3.nabble.com>
	<CAAfz9KOKj2rqsd6fBeqEcvMCMNMvcxK7S7AgF+rtmTiP9z27iQ@mail.gmail.com>
	<1534680422044-0.post@n3.nabble.com>
	<CAAfz9KNSf08FqKtu+b62x5kgFa8REmEftHp6ZfHE8um2xRZ14w@mail.gmail.com>
	<1534682790440-0.post@n3.nabble.com>
	<CAAfz9KMFNcG6cAzPn_A8T5YNGCuAzof0UKUP=MoR9kf6x0uK9A@mail.gmail.com>
	<1534683520743-0.post@n3.nabble.com>
	<CAAfz9KPXaBsMuEE-tvL1dnx9PXVopYc2SLVZL8B9nCzyasn4iA@mail.gmail.com>
	<1534684820114-0.post@n3.nabble.com>
	<CAAfz9KMkXro2X+uPW6ojVo0NatrUL-vzqjDEY2MNbq5SWjHsRQ@mail.gmail.com>

Dmitry Igrishin <dmitigr@gmail.com> writes:
> вс, 19 авг. 2018 г. в 16:20, TalGloz <glozmantal@gmail.com>:
>> I'll try it later when I'm home. Is there a reason that you are linking like
>> this
>> $(CXX) -Wl,--no-undefined -shared -o seal_diff_cpp.so $(LDFLAGS) $(LDLIBS)
>> seal_diff_cpp.o
>> And not like this?
>> $(CXX) -Wl,--no-undefined -shared -o seal_diff_cpp.so seal_diff_cpp.o
>> $(LDFLAGS) $(LDLIBS)

> If I recall correctly there were some problems with ordering arguments
> of the linker that are specified upon calling g++.

You're creating such problems, not solving them, if you put the library
first.  Particularly with .a-style libraries, you *must* list the
referencing .o file first, or the linker will deem the library
unreferenced and unnecessary.

None of this explains the failures on the core-backend symbol references,
though.  What platform is this?  I'm suspecting macOS or AIX, which
require the postgres executable to be explicitly mentioned when linking
.so's you intend to be loaded by postgres.  Most other platforms leave
such symbols to be resolved at runtime.

It might be a good idea to see if you can't use PGXS, which will deal
with a lot of these fine points for you.

			regards, tom lane




view thread (21+ messages)  latest in thread

Message-ID: <20033.1534690472@sss.pgh.pa.us>
Permalink:  ../20033.1534690472@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20033.1534690472@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dmitigr@gmail.com, glozmantal@gmail.com
  Subject: Re: Linker errors while creating a PostgreSQL C extension function.
  In-Reply-To: <20033.1534690472@sss.pgh.pa.us>
  References: <1534676183995-0.post@n3.nabble.com> <CAAfz9KOKj2rqsd6fBeqEcvMCMNMvcxK7S7AgF+rtmTiP9z27iQ@mail.gmail.com> <1534680422044-0.post@n3.nabble.com> <CAAfz9KNSf08FqKtu+b62x5kgFa8REmEftHp6ZfHE8um2xRZ14w@mail.gmail.com> <1534682790440-0.post@n3.nabble.com> <CAAfz9KMFNcG6cAzPn_A8T5YNGCuAzof0UKUP=MoR9kf6x0uK9A@mail.gmail.com> <1534683520743-0.post@n3.nabble.com> <CAAfz9KPXaBsMuEE-tvL1dnx9PXVopYc2SLVZL8B9nCzyasn4iA@mail.gmail.com> <1534684820114-0.post@n3.nabble.com> <CAAfz9KMkXro2X+uPW6ojVo0NatrUL-vzqjDEY2MNbq5SWjHsRQ@mail.gmail.com> <20033.1534690472@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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