Skip site navigation (1) Skip section navigation (2)

Re: cpp Makefiles

From: Lonnie Cumberland <lonnie_cumberland(at)yahoo(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: cpp Makefiles
Date: 2001-04-15 00:53:26
Message-ID: (view raw or whole thread)
Lists: pgsql-interfacespgsql-sql
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 ""

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/' 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
"" is created just fine.

I get the following messages:
[root(at)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.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 "".

This time the g++ compiler is called and I get:
g++    -c -o funcs.o 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,, or Makefile.port
because I cannot simply enter the same "gcc" line to get a usable "".

The reason that I need this to work is because I will be adding some c++
functions to the "" file and also need to be able to link in those
libraries as well.


Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.

In response to

pgsql-interfaces by date

Next:From: Giles LeanDate: 2001-04-15 00:59:26
Subject: Re: DBD::Pg 0.96 and DBI 1.15 ignoring username and password
Previous:From: Lonnie CumberlandDate: 2001-04-15 00:46:15
Subject: g++ not working for postgresql extension languages?

pgsql-sql by date

Next:From: Tom LaneDate: 2001-04-15 01:08:17
Subject: Re: [SQL] g++ not working for postgresql extension languages?
Previous:From: Tom LaneDate: 2001-04-15 00:50:52
Subject: Re: Full outer join

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group