building and linking C user defined functions for the native win32PG8.0 beta 3

Поиск
Список
Период
Сортировка
От Jean-Marc EBER
Тема building and linking C user defined functions for the native win32PG8.0 beta 3
Дата
Msg-id 416CE9F5.1050304@lexifi.com
обсуждение исходный текст
Ответы Re: building and linking C user defined functions  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-hackers-win32
Hi all,

As I learned that a native win32 version of PG would be available soon, I began
to look seriously at it (win32 support is necessary in our business). We began
with a 7.xx standard version under Linux. After a few days of learing and
documenting, we were able to create our own types, add user defined functions
written in C and returning sets etc. Worked very well and nicely. Fine (and
thanks to the Postgresql team!).

Now I tried to port this stuff to the win32 native version, building a dll that
can be dynamically loaded by PG at run-time.

Our steps:

1.    Download the self extracting binaries and install them. No major problems
encountered.
2.    Download the cvs 8.0beta3 snapshoot and build the native libpq.lib, libpq.dll
with nmake etc. Seemed to work well.
3.    Try to link our code for building a dll. Here the problem begins:

-----------------------------------------------------------
link /nologo /dll /libpath:"c:\Program Files\mlfi\lib" \
           /libpath:"C:\postgresql\postgresql-snapshot\src\interfaces\libpq\Relea
se" \
           /libpath:"c:\program files\Microsoft Visual Studio\VC98\Lib" \
           /out:libudfs_wrapper.dll \
   libpq.lib udfs.obj udfs_wrapper.obj postgresql/pg_wrapper.obj \
   libcamlrun.lib
pg_wrapper.obj : error LNK2001: unresolved external symbol _MemoryContextAlloc
pg_wrapper.obj : error LNK2001: unresolved external symbol __imp__CurrentMemoryC
ontext
pg_wrapper.obj : error LNK2001: unresolved external symbol _Float8GetDatum
pg_wrapper.obj : error LNK2001: unresolved external symbol _pg_detoast_datum
pg_wrapper.obj : error LNK2001: unresolved external symbol _end_MultiFuncCall
pg_wrapper.obj : error LNK2001: unresolved external symbol _per_MultiFuncCall
pg_wrapper.obj : error LNK2001: unresolved external symbol _MemoryContextSwitchT
o
pg_wrapper.obj : error LNK2001: unresolved external symbol _init_MultiFuncCall
libudfs_wrapper.dll : fatal error LNK1120: 8 unresolved externals
make: *** [libudfs_wrapper.dll] Error 96

-----------------------------------------------------------

If I understand well, libpq is a library for building PG clients, but doesn’t
contain "enough" functions to build "udf dlls".

So my question:

What is (or will be) the "official" way to achieve this goal for the win32 version ?

Did anybody achieve to build such a dll with native VC++ only (probably by
achieving to compile the transitive closure of what is needed in backend/utils) ?

Or is one supposed to build such a dll through the "cygwin way" ? This would
mean that one is taking a mingw or cygwin compiled PG (that should contain all
needed object files and library files as .a and .o files), compile and link the
own C udfs against these files for producing a dll ? Would such a dll be
compatible with the native win32 binary version ?

Jean-Marc Eber



В списке pgsql-hackers-win32 по дате отправления:

Предыдущее
От: "Noreen Jaster"
Дата:
Сообщение: Re: Static build of libpq fails
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: building and linking C user defined functions