Thread: Compiling UDF DLL under Win32
Hi! 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 ?
> 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
""Magnus Hagander"" <mha@sollentuna.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 >
> > 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. I was under the impression it didn't work even if you did that. But I've never tried it... //Magnus
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 > >
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