Re: Compiling extension C with MingW in windows, Error...

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Edwin Quijada <listas_quijada(at)hotmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Compiling extension C with MingW in windows, Error...
Date: 2010-09-06 08:02:52
Message-ID: AANLkTimwdAoy4Hdwj1QdOtbaMFogNpoPqEG5OBcucAmx@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Sep 3, 2010 at 18:23, Edwin Quijada <listas_quijada(at)hotmail(dot)com> wrote:
>
>> Date: Fri, 3 Sep 2010 09:41:17 +0200
>> Subject: Re: [GENERAL] Compiling extension C with MingW in windows,
>> Error...
>> From: magnus(at)hagander(dot)net
>> To: listas_quijada(at)hotmail(dot)com
>> CC: pgsql-general(at)postgresql(dot)org
>>
>> On Fri, Sep 3, 2010 at 5:31 AM, Edwin Quijada
>> <listas_quijada(at)hotmail(dot)com> wrote:
>> > Hi, I am tryng to compile a C extension in windows using Minigw but
>> > always I
>> > get the same error
>> >
>> > C:\Program Files\PostgreSQL\8.3\share\exte_c>C:\mingw\bin\gcc -shared -o
>> > pg2.dll
>> >  pg2.o
>> > pg2.o:pg2.c:(.text+0x86): undefined reference to
>> > `_imp__CurrentMemoryContext'
>> > pg2.o:pg2.c:(.text+0x92): undefined reference to `MemoryContextAlloc'
>> > collect2: ld returned 1 exit status
>> >
>> > This error is just when it links.
>>
>> You need to link against postgres.exe to get access to these symbols.
>> I don't recall if the mingw linker allows you to just specify the EXE
>> file these days, but I think it does. If not, you'll need to create an
>> import library from the EXE and link to that (the binary distribution
>> only ships with import libraries for MSVC, but mingw can't use
>> standard windows import libraries, so you need to create your own
>> there)
>
> Magnus how can I linking against postgres.exe I mean the gcc line. I did
> others function and worked fine

Sorry, I don't know this. I don't use mingw myself anymore. But it
should work in the same way as you link against any other third-party
DLLs with it - DLLs and EXEs are actually the same thing, just with
different names...

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Devrim GÜNDÜZ 2010-09-06 08:26:45 Re: FC13 RPMs for 9.0 - on postgresql.org ftp, but not in yum repo?
Previous Message Craig Ringer 2010-09-06 07:53:36 Re: FC13 RPMs for 9.0 - on postgresql.org ftp, but not in yum repo?