Re: Compiling UDF DLL under Win32

Lists: pgsql-hackers
From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: "anonymus(dot)crux" <anonymus(dot)crux(at)mail(dot)ee>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Compiling UDF DLL under Win32
Date: 2006-02-07 09:38:57
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCE6C7FBA@algol.sollentuna.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> I was wondering if I can use VC compiler to compile UDF DLL ?
> If yes then I am wondering why I am getting linking errors:
>
> Compiling...
> fd.c
> Linking...
> Creating library Debug/fd.lib and object Debug/fd.exp
> fd.obj : error LNK2001: unresolved external symbol
> _CurrentMemoryContext Debug/fd.dll : fatal error LNK1120: 1
> unresolved externals
>
>
> It seems that linker is not able to find symbol CurrentMemoryContext.
> This variable is declared in palloc.h, but I can't find the
> implementation of this variable in libpostgres.a ?

No, you need to use mingw to compile extensions.

//Magnus


From: "William ZHANG" <uniware(at)zedware(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Compiling UDF DLL under Win32
Date: 2006-02-07 15:03:03
Message-ID: dsada9$2iuo$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


""Magnus Hagander"" <mha(at)sollentuna(dot)net>
> No, you need to use mingw to compile extensions.

I think we should write some documents on how to generate
postgres.lib from postgres.exe for VC++, Borland C++ users.

> //Magnus
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>


From: "anonymus(dot)crux" <anonymus(dot)crux(at)mail(dot)ee>
To: Magnus Hagander <mha(at)sollentuna(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Compiling UDF DLL under Win32
Date: 2006-02-10 13:23:46
Message-ID: 43EC93E2.9030306@mail.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

hm, I'm still stuck: can't compile extension with mingw compiler.
I use Dev-CPP IDE (4.9.9.2) with MingW 3.7. Has it been tested to compile
extensions under XP with PostgresQL 8.1.2 ?

Al I get are compiler errors:

gcc.exe -c fd.c -o fd.o -I"C:/Dev-Cpp/include"
-I"D:/.Work/postgresql/postgresql-8.1.2/src/include"
-I"D:/.Work/postgresql/postgresql-8.1.2/src/include/port/win32"
-I"D:/.Work/postgresql/postgresql-8.1.2/src/include"
-I"D:/.Work/postgresql/postgresql-8.1.2/src/include/port/win32"
-DBUILDING_DLL=1 -DWIN32 -DWIN32_CLIENT_ONLY=0

D:/.Work/postgresql/postgresql-8.1.2/src/include/port/win32.h:181:
error: redefinition of typedef 'pid_t'
C:/Dev-Cpp/include/sys/types.h:75: error: previous declaration of
'pid_t' was here

In file included from
D:/.Work/postgresql/postgresql-8.1.2/src/include/postgres.h:48,
from fd.c:8:
D:/.Work/postgresql/postgresql-8.1.2/src/include/c.h:328: error:
redefinition of typedef 'sig_atomic_t'
C:/Dev-Cpp/include/signal.h:46: error: previous declaration of
'sig_atomic_t' was here

In file included from
D:/.Work/postgresql/postgresql-8.1.2/src/include/access/tupdesc.h:18,
from
D:/.Work/postgresql/postgresql-8.1.2/src/include/utils/rel.h:17,
from
D:/.Work/postgresql/postgresql-8.1.2/src/include/storage/bufmgr.h:21,
from
D:/.Work/postgresql/postgresql-8.1.2/src/include/storage/bufpage.h:18,

from
D:/.Work/postgresql/postgresql-8.1.2/src/include/access/htup.h:17,
from
D:/.Work/postgresql/postgresql-8.1.2/src/include/utils/tqual.h:18,
from
D:/.Work/postgresql/postgresql-8.1.2/src/include/access/relscan.h:18,
from
D:/.Work/postgresql/postgresql-8.1.2/src/include/nodes/execnodes.h:17,
from
D:/.Work/postgresql/postgresql-8.1.2/src/include/executor/execdesc.h:19,
from
D:/.Work/postgresql/postgresql-8.1.2/src/include/executor/executor.h:17,
from fd.c:10
.....
.....
.....

>>I was wondering if I can use VC compiler to compile UDF DLL ?
>>If yes then I am wondering why I am getting linking errors:
>>
>>Compiling...
>>fd.c
>>Linking...
>> Creating library Debug/fd.lib and object Debug/fd.exp
>>fd.obj : error LNK2001: unresolved external symbol
>>_CurrentMemoryContext Debug/fd.dll : fatal error LNK1120: 1
>>unresolved externals
>>
>>
>>It seems that linker is not able to find symbol CurrentMemoryContext.
>>This variable is declared in palloc.h, but I can't find the
>>implementation of this variable in libpostgres.a ?
>>
>>
>
>No, you need to use mingw to compile extensions.
>
>//Magnus
>
>---------------------------(end of broadcast)---------------------------
>TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>
>


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: "anonymus(dot)crux" <anonymus(dot)crux(at)mail(dot)ee>
Cc: Magnus Hagander <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Compiling UDF DLL under Win32
Date: 2006-02-10 14:18:23
Message-ID: 43ECA0AF.7020101@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Are you using pgxs + gmake? That's the best way to set up a UDF. We
recently made changes to ensure that pgxs works on Windows, and several
people have used it.

This could easily blow up on you: -I"C:/Dev-Cpp/include" - why do you
need to use the IDE's include files?

If you really need an IDE or something like it, native Windows XEmacs
works reasonably.

cheers

andrew

anonymus.crux wrote:

> hm, I'm still stuck: can't compile extension with mingw compiler.
> I use Dev-CPP IDE (4.9.9.2) with MingW 3.7. Has it been tested to compile
> extensions under XP with PostgresQL 8.1.2 ?
>
> Al I get are compiler errors:
>
> gcc.exe -c fd.c -o fd.o -I"C:/Dev-Cpp/include"
> -I"D:/.Work/postgresql/postgresql-8.1.2/src/include"
> -I"D:/.Work/postgresql/postgresql-8.1.2/src/include/port/win32"
> -I"D:/.Work/postgresql/postgresql-8.1.2/src/include"
> -I"D:/.Work/postgresql/postgresql-8.1.2/src/include/port/win32"
> -DBUILDING_DLL=1 -DWIN32 -DWIN32_CLIENT_ONLY=0
>
> D:/.Work/postgresql/postgresql-8.1.2/src/include/port/win32.h:181:
> error: redefinition of typedef 'pid_t'
> C:/Dev-Cpp/include/sys/types.h:75: error: previous declaration of
> 'pid_t' was here
>
> In file included from
> D:/.Work/postgresql/postgresql-8.1.2/src/include/postgres.h:48,
> from fd.c:8:
> D:/.Work/postgresql/postgresql-8.1.2/src/include/c.h:328: error:
> redefinition of typedef 'sig_atomic_t'
> C:/Dev-Cpp/include/signal.h:46: error: previous declaration of
> 'sig_atomic_t' was here
>
> In file included from
> D:/.Work/postgresql/postgresql-8.1.2/src/include/access/tupdesc.h:18,
> from
> D:/.Work/postgresql/postgresql-8.1.2/src/include/utils/rel.h:17,
> from
> D:/.Work/postgresql/postgresql-8.1.2/src/include/storage/bufmgr.h:21,
> from
> D:/.Work/postgresql/postgresql-8.1.2/src/include/storage/bufpage.h:18,
>
> from
> D:/.Work/postgresql/postgresql-8.1.2/src/include/access/htup.h:17,
> from
> D:/.Work/postgresql/postgresql-8.1.2/src/include/utils/tqual.h:18,
> from
> D:/.Work/postgresql/postgresql-8.1.2/src/include/access/relscan.h:18,
> from
> D:/.Work/postgresql/postgresql-8.1.2/src/include/nodes/execnodes.h:17,
> from
> D:/.Work/postgresql/postgresql-8.1.2/src/include/executor/execdesc.h:19,
> from
> D:/.Work/postgresql/postgresql-8.1.2/src/include/executor/executor.h:17,
> from fd.c:10