Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jUxyq-0000MD-8U for pgsql-general@arkaria.postgresql.org; Sat, 02 May 2020 19:39:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jUxyo-0005ZR-Is for pgsql-general@arkaria.postgresql.org; Sat, 02 May 2020 19:39:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jUxyo-0005XX-As for pgsql-general@lists.postgresql.org; Sat, 02 May 2020 19:39:18 +0000 Received: from n3.nabble.com ([162.255.23.22]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jUxyl-0006q6-PZ for pgsql-general@postgresql.org; Sat, 02 May 2020 19:39:17 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id BC3DA1D13DA5E for ; Sat, 2 May 2020 12:39:14 -0700 (MST) Date: Sat, 2 May 2020 12:39:14 -0700 (MST) From: TalGloz To: pgsql-general@postgresql.org Message-ID: <1588448354769-0.post@n3.nabble.com> In-Reply-To: <4edd59f3-4d95-c41c-6839-7d022946f8d4@aklaver.com> References: <1588447687198-0.post@n3.nabble.com> <4edd59f3-4d95-c41c-6839-7d022946f8d4@aklaver.com> Subject: Re: Compiling C Extension Functions against PostgreSQL 12 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Adrian Klaver-4 wrote > On 5/2/20 12:28 PM, TalGloz wrote: >> I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile all >> my >> manually created C extension functions against PostrgreSQL 12 before >> starting the upgrade process. I have this Makefile that compiles >> perfectly >> the seal_diff_cpp.cpp C extension function against PostgreSQL 10: >> >> MODULES = seal_diff_cpp >> PG_CONFIG = /usr/pgsql-10/bin/pg_config >> PGXS = $(shell $(PG_CONFIG) --pgxs) >> INCLUDEDIR = $(shell $(PG_CONFIG) --includedir-server) >> INCLUDE_SEAL = /usr/local/include >> INCLUDE_SEAL_LIB = /usr/local/lib >> INCLUDE_CPPCODEC = /usr/local/include/cppcodec >> CXX = g++ >> CXXFLAGS = -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread \ >> -I$(INCLUDEDIR) -I$(INCLUDE_SEAL) -I$(INCLUDE_CPPCODEC) >> SEAL_LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -pthread >> include $(PGXS) >> seal_diff_cpp.so: seal_diff_cpp.o >> # $(CXX) -Wl,--no-undefined -shared -o seal_diff_cpp.so >> seal_diff_cpp.o $(LDFLAGS) $(SEAL_LDFLAGS) >> $(CXX) -shared -o seal_diff_cpp.so seal_diff_cpp.o $(LDFLAGS) >> $(SEAL_LDFLAGS) >> seal_diff_cpp.o: seal_diff_cpp.cpp >> $(CXX) $(CXXFLAGS) -o seal_diff_cpp.o -c seal_diff_cpp.cpp >> >> When I execute it the output looks like this: >> >> g++ -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread >> -I/usr/pgsql-10/include/server -I/usr/local/include >> -I/usr/local/include/cppcodec -o seal_diff_cpp.o -c seal_diff_cpp.cpp >> g++ -shared -o seal_diff_cpp.so seal_diff_cpp.o -L/usr/pgsql-10/lib >> -L/usr/lib64 -Wl,--as-needed >> -Wl,-rpath,'/usr/pgsql-10/lib',--enable-new-dtags -L/usr/local/lib -lseal >> -pthread >> >> And the seal_diff_cpp.so gets created without any problems. But when I >> use >> PG_CONFIG = /usr/pgsql-12/bin/pg_config I get: >> >> g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute >> -Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c >> seal_diff_cpp.cpp >> seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or >> directory >> 2 | #include > >> | ^~~~~~~~~~~~ >> compilation terminated. >> make: *** [Makefile:19: seal_diff_cpp.o] Error 1 >> >> The Makefile has all the needed information to compile the >> seal_diff_cpp.so >> against PostgreSQL 12: >> /usr/pgsql-10/bin/pg_config --pgxs ---> >> /usr/pgsql-10/lib/pgxs/src/makefiles/pgxs.mk >> /usr/pgsql-12/bin/pg_config --pgxs ---> >> /usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk >> >> /usr/pgsql-10/bin/pg_config --includedir-server ---> >> /usr/pgsql-10/include/server >> /usr/pgsql-12/bin/pg_config --includedir-server ---> >> /usr/pgsql-12/include/server (postgres.h is there) >> >> I can't understand why it doesn't work. > > Do you have Postgres 12 -dev package installed? > >> >> TalGloz >> >> >> >> -- >> Sent from: >> https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html >> >> > > > -- > Adrian Klaver > adrian.klaver@ Yes, I've installed everything PostgreSQL 12 has to offer: dnf list installed | grep "postgresql12" postgresql12.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-contrib.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-devel.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-docs.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-libs.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-llvmjit.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-odbc.x86_64 12.01.0000-1PGDG.f31 @pgdg12 postgresql12-plperl.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-plpython.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-plpython3.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-pltcl.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-server.x86_64 12.2-2PGDG.f31 @pgdg12 postgresql12-tcl.x86_64 2.4.0-2.f31.2 @pgdg12 postgresql12-test.x86_64 12.2-2PGDG.f31 @pgdg12 -- Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html