Re: Re: [SQL] g++ not working for postgresql extension languages?

From: Lonnie Cumberland <lonnie_cumberland(at)yahoo(dot)com>
To: Stephen Jackson <Stephen(dot)Jackson(at)panting-deer(dot)org(dot)uk>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Re: [SQL] g++ not working for postgresql extension languages?
Date: 2001-04-15 18:20:11
Message-ID: 20010415182011.1844.qmail@web12508.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces pgsql-sql

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(at)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(dot)Jackson(at)panting-deer(dot)org(dot)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(dot)Jackson(at)panting-deer(dot)org(dot)uk www.panting-deer.org.uk
> Work: Stephen(dot)Jackson(at)looksystems(dot)co(dot)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/

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Peter Eisentraut 2001-04-15 19:52:30 Re: Re: [SQL] g++ not working for postgresql extension languages?
Previous Message Stephen Jackson 2001-04-15 16:10:29 Re: [SQL] g++ not working for postgresql extension languages?

Browse pgsql-sql by date

  From Date Subject
Next Message Nelson Ferreira Jr 2001-04-15 18:52:56 Re: How to store gif or jpeg? Thanks!
Previous Message Christof Glaser 2001-04-15 17:24:00 Re: [SQL] How to simulate MEMO data type?Thanks!