From: Lonnie Cumberland <lonnie_cumberland@yahoo.com>
To: Stephen Jackson <Stephen.Jackson@panting-deer.org.uk>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: Re: [SQL] g++ not working for postgresql extension languages?
Date: Sun, 15 Apr 2001 11:20:11 -0700 (PDT)
Message-ID: <20010415182011.1844.qmail@web12508.mail.yahoo.com> (raw)
In-Reply-To: <3AD9C7F5.902BAE74@panting-deer.org.uk>
Hello All,
I have gotten the EXTERN "C" statement to work with the simple test c++
functions, but I cannot get it to work with the my actual crypto4.0 c++ sources
which I am able to compile all together into a single funcs.so file.
I am getting no errors but when I go into the "psql trdata" and try the same
test then I get this error:
[root@Treazurac /test]# psql trdata
Welcome to psql, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
trdata=# select concat_text('a','d');
ERROR: Load of file /test/trfuncs.so failed: /test/trfuncs.so: undefined
symbol: MemoryContextAlloc__FP17MemoryContextDataUi
-----------------------------------------------------------------------------
I do not know what is going on here because I did a simple test without my
cyrpto4.0 c++ files and using 3 different copies of concat_text(),
concat1_text() and concat2_text() which compiled and even ran fine.
now when I put in my other sources which compile correctly outside of
Postgresql, I get the above error.
I have zipped up the test files and will send them to someone if you would like
to take a quick look. Just let me know as I am at a loss as to why PostgreSQL
is having som much trouble with this C++ interface.
Cheers
Lonnie
--- Stephen Jackson <Stephen.Jackson@panting-deer.org.uk> wrote:
> Lonnie,
>
> C++ uses "name mangling" to permit overloading of functions. Therefore
> your function concat_text() ends up with a very different name. You can
> probably get round this as follows:
>
> #ifdef __cplusplus
> extern "C" {
> #endif
> text *
> concat_text(text *arg1, text *arg2);
> #ifdef __cplusplus
> }
> #endif
>
> This tells the C++ compiler that concat_text is a "C" name - so don't do
> name mangling. This is a common technique for making C++ code callable
> from C, although I haven't used it in the specific context you are
> using.
>
> Hope this helps,
>
> Stephen Jackson
> Home: Stephen.Jackson@panting-deer.org.uk www.panting-deer.org.uk
> Work: Stephen.Jackson@looksystems.co.uk www.looksystems.co.uk
>
> Lonnie Cumberland wrote:
> >
> > Hi All again,
> >
> > One more thing that I have tried.
> >
> > If I now do a similar thing as in my previous message with the "funcs.c"
> file,
> > but this time with the "funcs.cc" file then I can get:
> >
>
> [snip]
>
> >
> > trdata=# select concat_text('a','b');
> > ERROR: Can't find function concat_text in file /test/funcs.so
> > trdata=#
> > --------------------------------------------------------------------------
> >
>
> [snip]
>
> >
> > text *
> > concat_text(text *arg1, text *arg2);
> >
>
> [snip]
>
> > so now I do not understand why the "gcc" version works and the "g++"
> version
> > does not?
> >
> > Just a side note in that I can easliy compile c++ the examples in the
> > interfaces/libpq++ directory without any problems so that this is very
> strange
> > to me.
> >
> > I really need the "g++" version to work correctly as well?
> >
> > Any ideas anyone?
> >
> > Cheers
> > Lonnie
> >
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
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 using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: lonnie_cumberland@yahoo.com, Stephen.Jackson@panting-deer.org.uk
Subject: Re: Re: [SQL] g++ not working for postgresql extension languages?
In-Reply-To: <20010415182011.1844.qmail@web12508.mail.yahoo.com>
* 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