Received: from web12503.mail.yahoo.com (web12503.mail.yahoo.com [216.136.173.195]) by postgresql.org (8.11.3/8.11.1) with SMTP id f3F0rRu71391 for ; Sat, 14 Apr 2001 20:53:28 -0400 (EDT) (envelope-from lonnie_cumberland@yahoo.com) Message-ID: <20010415005326.23512.qmail@web12503.mail.yahoo.com> Received: from [141.217.140.65] by web12503.mail.yahoo.com; Sat, 14 Apr 2001 17:53:26 PDT Date: Sat, 14 Apr 2001 17:53:26 -0700 (PDT) From: Lonnie Cumberland Subject: Re: cpp Makefiles To: Peter Eisentraut Cc: pgsql-interfaces@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200104/36 X-Sequence-Number: 1419 Hello Peter, I am in the process of downloading the new 7.1 PostgreSQL and will update my system from the 7.03 version. Actually there is not a problem in compiling the examples in the interfaces/libpq++ directory and those work just fine. I will try to explain the problem and the steps that I have taken to get that problem generated in the hopes that it will help illuminate the error. I have a simple test function: ----------------------------------------------------------------------------- #include "postgres.h" // for variable length type #include #include #include #include #include // for unix crypt function text * concat_text(text *arg1, text *arg2); text * concat_text(text *arg1, text *arg2) { int32 new_text_size = VARSIZE(arg1) + VARSIZE(arg2) - VARHDRSZ; text *new_text = (text *) malloc(new_text_size); memset((void *) new_text, 0, new_text_size); VARSIZE(new_text) = new_text_size; strncpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1)-VARHDRSZ); strncat(VARDATA(new_text), VARDATA(arg2), VARSIZE(arg2)-VARHDRSZ); return (new_text); } ------------------------------------------------------------------------- which I have saved as two different files for testing: files: "funcs.c" and "funcs.cc" load into the pgsql command interpreter the registration of this function: "psql -f funcs.sql -d trdata" the "funcs.sql" is simply: ------------------------------------------------------------------------------ DROP FUNCTION concat_text(text, text); CREATE FUNCTION concat_text(text, text) RETURNS text AS '/treazurac/funcs.so' LANGUAGE 'c'; ------------------------------------------------------------------------------ Now then, the two different outcomes are: Outcome A: 1. I do a "make" with just the "funcs.c" program in the directory and the "funcs.so" is created just fine. I get the following messages: ------------------------------------------------------------------------- [root@Treazurac /test]# make gcc -I./include -I./backend -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -I/usr/include/pgsql -I/usr/include -fpic -c -o funcs.o funcs.c gcc -shared -o funcs.so funcs.o rm funcs.o ---------------------------------------------------------------------------- 2. Enter the "psql trdata" 3. do a "select concat_text('a','b'); and the result is a string "ab" just as expected. Outcome B: 1. I do a "make" with just the "funcs.cc". This time the g++ compiler is called and I get: ------------------------------------------------------------------------- g++ -c -o funcs.o funcs.cc funcs.cc:23: postgres.h: No such file or directory make: *** [funcs.o] Error 1 -------------------------------------------------------------------------- I have tried adjusting the INCLUDES and LIB paths but is seems that there is some other things going on in the Makefile, Makefile.global, or Makefile.port because I cannot simply enter the same "gcc" line to get a usable "funcs.so". The reason that I need this to work is because I will be adding some c++ functions to the "funcs.cc" file and also need to be able to link in those libraries as well. Cheers, Lonnie __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/