Re: cpp Makefiles
От | Lonnie Cumberland |
---|---|
Тема | Re: cpp Makefiles |
Дата | |
Msg-id | 20010415002322.69371.qmail@web12502.mail.yahoo.com обсуждение исходный текст |
Ответ на | Re: cpp Makefiles (Peter Eisentraut <peter_e@gmx.net>) |
Список | pgsql-interfaces |
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 <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #include <unistd.h> // 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/
В списке pgsql-interfaces по дате отправления:
Следующее
От: "Brett W. McCoy"Дата:
Сообщение: DBD::Pg 0.96 and DBI 1.15 ignoring username and password