Re: Postgres 7.1RC4 ecpg can't find sqlca

From: lemkemch(at)t-online(dot)de (Michael Lemke)
To: Jason Tishler <Jason(dot)Tishler(at)dothill(dot)com>
Cc: cygwin(at)cygwin(dot)com, Pgsql-Ports <pgsql-ports(at)postgresql(dot)org>
Subject: Re: Postgres 7.1RC4 ecpg can't find sqlca
Date: 2001-04-14 10:25:37
Message-ID: 14oNFK-1jO9C4C@fwd06.sul.t-online.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-cygwin pgsql-ports

4/14/01 00:08:14, Jason Tishler <Jason(dot)Tishler(at)dothill(dot)com> wrote:

>
>On Fri, Apr 13, 2001 at 11:02:23PM +0200, Michael Lemke wrote:
>> With the latest postgres release that came lately with cygwin I made my
>> very first attempt at writng an ESQL program (actually, at the moment it
>> is just something I dowloaded). Now when I link it can't find sqlca:
>>
>> michael> gcc -I /usr/include/postgresql/ esql.c -lecpg -lpq
>> /f/cygwin~1/tmp/ccbnOeiG.o(.text+0x203):esql.c: undefined reference to `sqlca'
>> /f/cygwin~1/tmp/ccbnOeiG.o(.text+0x292):esql.c: undefined reference to `sqlca'
>> collect2: ld returned 1 exit status
>>
>> ecpg made the declaration of sqlca
>>
>> extern struct sqlca sqlca;
>
>I believe that the above is a bug in sqlca.h. My WAG (without actually
>trying this) is that the above should be replaced by the following:
>
>#ifdef __CYGWIN__
> extern __declspec(dllimport) struct sqlca sqlca;
>#else
> extern struct sqlca sqlca;
>

Jason,

thanks a lot. That did the trick. I didn't try the one below. It's up
to the experts to decide which way to go.

>or by
>
>#ifdef __CYGWIN__
> extern DLLIMPORT struct sqlca sqlca;
>#else
> extern struct sqlca sqlca;
>
>if c.h can be safely included.
>
>> I recompiled postgres and skipped stripping of the libraries. Then I find
>> sqlca in ecpg.dll:
>>
>> michael> nm /usr/bin/ecpg.dll | grep sqlca
>> c0586864 T _init_sqlca
>> c0587000 D _sqlca
>> c05870b0 d _sqlca_init
>
>Don't worry sqlca *is* exported from ecpg.dll:
>
> $ objdump -p /usr/bin/ecpg.dll | fgrep sqlca
> [ 28] init_sqlca
> [ 29] sqlca
>
>> but not in libecpg.a:
>>
>> michael> nm /usr/lib/libecpg.a | grep sqlca
>> 00000000 I __imp__sqlca
>> 00000000 I __imp__init_sqlca
>> 00000000 T _init_sqlca
>
>Actually, sqlca *is* in the import library but it is called
>"__imp__sqlca" as it should be.
>
>Does changing your sqlca.h as above fix your problem. If so, then I
>will submit a patch to the pgsql-ports mailing list.
>
>Are there other ESQL related symbols that need the __declspec(dllimport)
>attribute too?

I don't know. I am just trying to learn ESQL but I'll let you know if
I come across another one.

Thanks again,
Michael

Responses

Browse pgsql-cygwin by date

  From Date Subject
Next Message Tulassay Zsolt 2001-04-14 16:05:27 Re: initdb problem
Previous Message Jason Tishler 2001-04-13 15:48:55 Re: Fw: Postgres on WinNT4 / SP5

Browse pgsql-ports by date

  From Date Subject
Next Message Jason Tishler 2001-04-14 14:13:03 Re: running
Previous Message kevin mclaughlin 2001-04-14 10:08:32 Re: Fw: porting to AIX