Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1frP6H-0004n6-0w for pgsql-general@arkaria.postgresql.org; Sun, 19 Aug 2018 14:54:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1frP6E-0003cK-RG for pgsql-general@arkaria.postgresql.org; Sun, 19 Aug 2018 14:54:38 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1frP6E-0003cC-Fn for pgsql-general@lists.postgresql.org; Sun, 19 Aug 2018 14:54:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1frP6B-0004tv-MQ for pgsql-general@postgresql.org; Sun, 19 Aug 2018 14:54:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w7JEsWtf020034; Sun, 19 Aug 2018 10:54:32 -0400 From: Tom Lane To: Dmitry Igrishin cc: Tal Glozman , pgsql-general@postgresql.org Subject: Re: Linker errors while creating a PostgreSQL C extension function. In-reply-to: References: <1534676183995-0.post@n3.nabble.com> <1534680422044-0.post@n3.nabble.com> <1534682790440-0.post@n3.nabble.com> <1534683520743-0.post@n3.nabble.com> <1534684820114-0.post@n3.nabble.com> Comments: In-reply-to Dmitry Igrishin message dated "Sun, 19 Aug 2018 17:28:52 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <20032.1534690472.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 19 Aug 2018 10:54:32 -0400 Message-ID: <20033.1534690472@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Dmitry Igrishin writes: > =D0=B2=D1=81, 19 =D0=B0=D0=B2=D0=B3. 2018 =D0=B3. =D0=B2 16:20, TalGloz = : >> 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) $(LDLI= BS) >> 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