Re: How to compile, link and use a C++ extension - Mailing list pgsql-hackers

From Andres Freund
Subject Re: How to compile, link and use a C++ extension
Date
Msg-id 20150814165153.GK4955@awork2.anarazel.de
Whole thread Raw
In response to How to compile, link and use a C++ extension  (jacques klein <jacques.klei@googlemail.com>)
Responses Re: How to compile, link and use a C++ extension  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: How to compile, link and use a C++ extension  (Craig Ringer <craig@2ndquadrant.com>)
List pgsql-hackers
Hi,

On 2015-08-14 18:38:36 +0200, jacques klein wrote:
> However I coudn't find any doc. about how to solve the problem of linking
> C++ code and libs into the .so of my extension,
> and nothing to solve the runtime-loading problem of the c++ specific .so
> files ( for ex. to make work a simple usage std::string )

libstdc++ (or whatever your platform uses) should be automatically
loaded, I don't think you'll need to worry about that.

> I started my tests by cloning the contrib/worker_spi code, and when
> transforming the code into C++, I could only note that C++ is not supported
> in the provided Makefiles.

Yes, that doesn't surprise me. Postgres itself doesn't need to care
about looking for a usable C++ compiler et al.

How exactly do you need to use the C++ code? The easiest probably would
be to have a separate object file, built using your own makefile rule,
that contains a the C++ and provides a C interface, and then use that
from a background worker purely written in C.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: jacques klein
Date:
Subject: How to compile, link and use a C++ extension
Next
From: Tom Lane
Date:
Subject: Re: How to compile, link and use a C++ extension