Обсуждение: Building psql.exe using the free Borland compiler

Поиск
Список
Период
Сортировка

Building psql.exe using the free Borland compiler

От
Mark Morgan Lloyd
Дата:
Has anybody succeeded in building psql from 8.1.3 using bcc55? I've got
everything going OK up to the final link stage at which point I get

ilink32.exe @MAKE0000.@@@
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '_pclose' referenced from
C:\USR\SRC\POSTGRES\POSTGRESQL-8.1.3\SRC\BIN\PSQL\RELEASE\EXEC.OBJ

with a similar error for _popen. I'm using a source tree which has compiled OK
under Linux to save the hassle of making sure I have a working perl/flex on the
Windows system, have made sure that it's using pg_config.h.win32, and can see
blibpq.dll being rebuilt. I've got an ilink32.cfg file containing
-L"c:\usr\local\Bcc55\lib" where this directory contains cw32mti.lib etc.

Apologies if this is a really dumb question. I don't /do/ C/C++ on Windows, I'm
much more a bare-metal guy who does Delphi and Perl when he needs high-level.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]


Re: Building psql.exe using the free Borland compiler

От
Mark Morgan Lloyd
Дата:
Mark Morgan Lloyd wrote:
> 
> Has anybody succeeded in building psql from 8.1.3 using bcc55?

Well, looks like it's me then. Skipping the standard stuff to do with setting up
the compiler and selecting the correct makefiles, and with the strong caveat
that this is for BCC 5.5 and is untested against earlier and later Borland
compilers:

i)   Delete src\include\pg_config.h if it exists, it's recreated by the
makefile.

ii)  Modify src\interfaces\libpq\pg_config_paths.h so that instead of reading:

#define SYSCONFDIR

it reads:

#define SYSCONFDIR ""

iii) Modify src\include\port.h so that instead of reading:

#ifndef __BORLANDC__
#define popen(a,b) _popen(a,b)
#define pclose(a) _pclose(a)
#endif

it reads:

// ifndef __BORLANDC__
#define popen(a,b) _popen(a,b)
#define pclose(a) _pclose(a)
// endif

Should now compile and run without problems.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]


Re: Building psql.exe using the free Borland compiler

От
Bruce Momjian
Дата:
Mark Morgan Lloyd wrote:
> Mark Morgan Lloyd wrote:
> >
> > Has anybody succeeded in building psql from 8.1.3 using bcc55?
>
> Well, looks like it's me then. Skipping the standard stuff to do with setting up
> the compiler and selecting the correct makefiles, and with the strong caveat
> that this is for BCC 5.5 and is untested against earlier and later Borland
> compilers:
>
> i)   Delete src\include\pg_config.h if it exists, it's recreated by the
> makefile.

Why remove the file if it is overwritten anyway?

> ii)  Modify src\interfaces\libpq\pg_config_paths.h so that instead of reading:
>
> #define SYSCONFDIR
>
> it reads:
>
> #define SYSCONFDIR ""

OK, I originally had in the Makefile:

   echo \#define SYSCONFDIR "" > pg_config_paths.h

I changed it to:

   echo \#define SYSCONFDIR \"\" > pg_config_paths.h

I hope that properly puts quotes in the file.

> iii) Modify src\include\port.h so that instead of reading:
>
> #ifndef __BORLANDC__
> #define popen(a,b) _popen(a,b)
> #define pclose(a) _pclose(a)
> #endif
>
> it reads:
>
> // ifndef __BORLANDC__
> #define popen(a,b) _popen(a,b)
> #define pclose(a) _pclose(a)
> // endif
>
> Should now compile and run without problems.

Done.  Applied patch attached.

--
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/include/port.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/port.h,v
retrieving revision 1.90
diff -c -c -r1.90 port.h
*** src/include/port.h    5 Mar 2006 15:58:53 -0000    1.90
--- src/include/port.h    24 Apr 2006 03:57:37 -0000
***************
*** 255,264 ****
  #define        open(a,b,...)    win32_open(a,b,##__VA_ARGS__)
  #endif

- #ifndef __BORLANDC__
  #define popen(a,b) _popen(a,b)
  #define pclose(a) _pclose(a)
- #endif

  /* Missing rand functions */
  extern long lrand48(void);
--- 255,262 ----
Index: src/interfaces/libpq/bcc32.mak
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/libpq/bcc32.mak,v
retrieving revision 1.20
diff -c -c -r1.20 bcc32.mak
*** src/interfaces/libpq/bcc32.mak    16 Sep 2005 19:00:05 -0000    1.20
--- src/interfaces/libpq/bcc32.mak    24 Apr 2006 03:57:44 -0000
***************
*** 141,147 ****

  # Have to use \# so # isn't treated as a comment, but MSVC doesn't like this
  pg_config_paths.h: bcc32.mak
!     echo \#define SYSCONFDIR "" > pg_config_paths.h

  "$(OUTDIR)" :
      @if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
--- 141,147 ----

  # Have to use \# so # isn't treated as a comment, but MSVC doesn't like this
  pg_config_paths.h: bcc32.mak
!     echo \#define SYSCONFDIR \"\" > pg_config_paths.h

  "$(OUTDIR)" :
      @if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"

Re: Building psql.exe using the free Borland compiler

От
ljb
Дата:
Found this in the archive from a month or so ago:

>> > Has anybody succeeded in building psql from 8.1.3 using bcc55?
>> ...
> OK, I originally had in the Makefile:
>
>    echo \#define SYSCONFDIR "" > pg_config_paths.h
>
> I changed it to:
>
>    echo \#define SYSCONFDIR \"\" > pg_config_paths.h
>
> I hope that properly puts quotes in the file.
>...
>
> Done.  Applied patch attached.

This change is causing me grief when trying to compile libpq from
PostgreSQL-8.1.4 using Borland BCC32. The above echo command puts
exactly this into my pg_config_paths.h:       #define SYSCONFDIR \"\"
which irks the compiler when building fe-connect.c
I had to change it to this in the Makefile:     echo \#define SYSCONFDIR "" > pg_config_paths.h
Before suggesting undoing this patch, can anyone else verify which version
works for them?


Re: Building psql.exe using the free Borland compiler

От
Alvaro Herrera
Дата:
ljb wrote:
> Found this in the archive from a month or so ago:
> 
> >> > Has anybody succeeded in building psql from 8.1.3 using bcc55?
> >> ...
> > OK, I originally had in the Makefile:
> >
> >    echo \#define SYSCONFDIR "" > pg_config_paths.h
> >
> > I changed it to:
> >
> >    echo \#define SYSCONFDIR \"\" > pg_config_paths.h
> >
> > I hope that properly puts quotes in the file.

> This change is causing me grief when trying to compile libpq from
> PostgreSQL-8.1.4 using Borland BCC32. The above echo command puts
> exactly this into my pg_config_paths.h:
>         #define SYSCONFDIR \"\"

Maybe we should use

echo -e \#define SYSCONFDIR \"\" > pg_config_paths.h

in the Makefile instead.  Does that work for you?

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: Building psql.exe using the free Borland compiler

От
Bruce Momjian
Дата:
Alvaro Herrera wrote:
> ljb wrote:
> > Found this in the archive from a month or so ago:
> > 
> > >> > Has anybody succeeded in building psql from 8.1.3 using bcc55?
> > >> ...
> > > OK, I originally had in the Makefile:
> > >
> > >    echo \#define SYSCONFDIR "" > pg_config_paths.h
> > >
> > > I changed it to:
> > >
> > >    echo \#define SYSCONFDIR \"\" > pg_config_paths.h
> > >
> > > I hope that properly puts quotes in the file.
> 
> > This change is causing me grief when trying to compile libpq from
> > PostgreSQL-8.1.4 using Borland BCC32. The above echo command puts
> > exactly this into my pg_config_paths.h:
> >         #define SYSCONFDIR \"\"
> 
> Maybe we should use
> 
> echo -e \#define SYSCONFDIR \"\" > pg_config_paths.h
> 
> in the Makefile instead.  Does that work for you?

Uh, the echo is interpreted by the borland Makefile utility.  I don't
think that understands -e.

--  Bruce Momjian   http://candle.pha.pa.us EnterpriseDB    http://www.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


Re: Building psql.exe using the free Borland compiler

От
Alvaro Herrera
Дата:
Bruce Momjian wrote:
> Alvaro Herrera wrote:

> > > This change is causing me grief when trying to compile libpq from
> > > PostgreSQL-8.1.4 using Borland BCC32. The above echo command puts
> > > exactly this into my pg_config_paths.h:
> > >         #define SYSCONFDIR \"\"
> > 
> > Maybe we should use
> > 
> > echo -e \#define SYSCONFDIR \"\" > pg_config_paths.h
> > 
> > in the Makefile instead.  Does that work for you?
> 
> Uh, the echo is interpreted by the borland Makefile utility.  I don't
> think that understands -e.

Yeah.  Maybe it can be done in some other way, how about

echo -e '#define SYSCONFDIR ""' > pg_config_paths.h

but ISTM ljb is the one who needs to find what works ...

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: Building psql.exe using the free Borland compiler

От
ljb
Дата:
pgman@candle.pha.pa.us wrote:
>...
> > 
> > This change is causing me grief when trying to compile libpq from
> > PostgreSQL-8.1.4 using Borland BCC32. The above echo command puts
> > exactly this into my pg_config_paths.h:
> >         #define SYSCONFDIR \"\"
> > which irks the compiler when building fe-connect.c
> > I had to change it to this in the Makefile:
> >       echo \#define SYSCONFDIR "" > pg_config_paths.h
> > Before suggesting undoing this patch, can anyone else verify which version
> > works for them?
> 
> Yes, I am getting confused why it works sometimes and not others.  Are
> you using bcc55?  Does this work:
> 
>     echo '#define SYSCONFDIR ""' > pg_config_paths.h

Yes, bcc55. In case it matters, using Windows 2000.
You say echo is done by Borland make - are you sure? I thought maybe it was
just passed to the command processor cmd.exe. It doesn't seem to do
anything special with quotes - justs outputs them - but I will do some more
checking with "'\ in a Makefile (on Tuesday, when I'm back where the
Windows PC lives.)

It would be interesting to hear from the original poster who
changed "" to \"\" to find out what his environment is.

By the way, I also had to put "#define inline" into pg_config.h.win32
after #ifdef __BORLANDC__, or the compilation failed in
backend/utils/mb/wchar.c (keep in mind I'm only building libpq here).


Re: Building psql.exe using the free Borland compiler

От
ljb
Дата:
alvherre@commandprompt.com wrote:
>...
> but ISTM ljb is the one who needs to find what works ...

Here's my Makefile for testing this:
===========================
all: f1 f2 f3 f4 f5 f6
f1:echo \#define SYSCONFDIR "" > f1
f2:echo \#define SYSCONFDIR \"\" > f2
f3:echo "#define SYSCONFDIR \"\"" > f3
f4:echo '\#define SYSCONFDIR ""' > f4
f5:echo '#define SYSCONFDIR ""' > f5
f6:echo #define SYSCONFDIR "" > f6
===========================
I'm using make from "Borland C++ 5.5.1 for Win32" on Windows 2000.
Here are the results for the first 4 cases:
f1: #define SYSCONFDIR "" 
f2: #define SYSCONFDIR \"\" 
f3: "#define SYSCONFDIR \"\"" 
f4: '#define SYSCONFDIR ""' 

Cases 'f5' and 'f6' don't produce output files at all.

So it seems to me that the patch to bcc32.mak should be reverted (as shown
below), but that depends on what the original poster (Mark Morgan Lloyd)
says. If he says the patch is needed, we should figure out why we get
different results.

--- src/interfaces/libpq/bcc32.mak.orig    2006-04-24 00:03:42.000000000 -0400
+++ src/interfaces/libpq/bcc32.mak    2006-05-30 19:40:31.000000000 -0400
@@ -141,7 +141,7 @@# Have to use \# so # isn't treated as a comment, but MSVC doesn't like thispg_config_paths.h:
bcc32.mak
-    echo \#define SYSCONFDIR \"\" > pg_config_paths.h
+    echo \#define SYSCONFDIR "" > pg_config_paths.h"$(OUTDIR)" :    @if not exist "$(OUTDIR)/$(NULL)" mkdir
"$(OUTDIR)"


Re: Building psql.exe using the free Borland compiler

От
Bruce Momjian
Дата:
[ CC added for Mark Morgan Lloyd]

Mark, can you comment on this?  Borland C++ 5.5.1 handles echo
differently than it does on your machine.

As far as echo, I think you are right that the Win32 command processor
is the one handling that, but I assumed the backslashes were handled by
the Makefile, hence the need for \#.

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

ljb wrote:
> alvherre@commandprompt.com wrote:
> >...
> > but ISTM ljb is the one who needs to find what works ...
> 
> Here's my Makefile for testing this:
> ===========================
> all: f1 f2 f3 f4 f5 f6
> f1:
>     echo \#define SYSCONFDIR "" > f1
> f2:
>     echo \#define SYSCONFDIR \"\" > f2
> f3:
>     echo "#define SYSCONFDIR \"\"" > f3
> f4:
>     echo '\#define SYSCONFDIR ""' > f4
> f5:
>     echo '#define SYSCONFDIR ""' > f5
> f6:
>     echo #define SYSCONFDIR "" > f6
> ===========================
> I'm using make from "Borland C++ 5.5.1 for Win32" on Windows 2000.
> Here are the results for the first 4 cases:
> f1: #define SYSCONFDIR "" 
> f2: #define SYSCONFDIR \"\" 
> f3: "#define SYSCONFDIR \"\"" 
> f4: '#define SYSCONFDIR ""' 
> 
> Cases 'f5' and 'f6' don't produce output files at all.
> 
> So it seems to me that the patch to bcc32.mak should be reverted (as shown
> below), but that depends on what the original poster (Mark Morgan Lloyd)
> says. If he says the patch is needed, we should figure out why we get
> different results.
> 
> --- src/interfaces/libpq/bcc32.mak.orig    2006-04-24 00:03:42.000000000 -0400
> +++ src/interfaces/libpq/bcc32.mak    2006-05-30 19:40:31.000000000 -0400
> @@ -141,7 +141,7 @@
>  
>  # Have to use \# so # isn't treated as a comment, but MSVC doesn't like this
>  pg_config_paths.h: bcc32.mak
> -    echo \#define SYSCONFDIR \"\" > pg_config_paths.h
> +    echo \#define SYSCONFDIR "" > pg_config_paths.h
>  
>  "$(OUTDIR)" :
>      @if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
> 

--  Bruce Momjian   http://candle.pha.pa.us EnterpriseDB    http://www.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


Re: Building psql.exe using the free Borland compiler

От
ljb
Дата:
pgman@candle.pha.pa.us wrote:
>...
> As far as echo, I think you are right that the Win32 command processor
> is the one handling that, but I assumed the backslashes were handled by
> the Makefile, hence the need for \#.

Sort of.  It looks to me like \# is handled by make when reading the
Makefile, resulting in a # which is not the start of a Makefile comment.
But it also seems that \ followed by anything else is not handled specially,
but simply passed through to the command.


Re: Building psql.exe using the free Borland compiler

От
Bruce Momjian
Дата:
With no report back from markMLl, I have changed the BCC code to use ""
rather than \"\".  Backpatched to 8.1.X.

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

ljb wrote:
> pgman@candle.pha.pa.us wrote:
> >...
> > As far as echo, I think you are right that the Win32 command processor
> > is the one handling that, but I assumed the backslashes were handled by
> > the Makefile, hence the need for \#.
> 
> Sort of.  It looks to me like \# is handled by make when reading the
> Makefile, resulting in a # which is not the start of a Makefile comment.
> But it also seems that \ followed by anything else is not handled specially,
> but simply passed through to the command.
> 
> ---------------------------(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
> 

--  Bruce Momjian   http://candle.pha.pa.us EnterpriseDB    http://www.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


Re: Building psql.exe using the free Borland compiler

От
Mark Morgan Lloyd
Дата:
I'm more than happy to defer to experienced C developers. I'm an
assembler/Modula-2/Delphi/Perl man, and whilst I've got some appreciation of the
issues I am in no way a competent C/C++ or makefile programmer.


ljb wrote:

> So it seems to me that the patch to bcc32.mak should be reverted (as shown
> below), but that depends on what the original poster (Mark Morgan Lloyd)
> says. If he says the patch is needed, we should figure out why we get
> different results.
> 
> --- src/interfaces/libpq/bcc32.mak.orig 2006-04-24 00:03:42.000000000 -0400
> +++ src/interfaces/libpq/bcc32.mak      2006-05-30 19:40:31.000000000 -0400
> @@ -141,7 +141,7 @@
> 
>  # Have to use \# so # isn't treated as a comment, but MSVC doesn't like this
>  pg_config_paths.h: bcc32.mak
> -       echo \#define SYSCONFDIR \"\" > pg_config_paths.h
> +       echo \#define SYSCONFDIR "" > pg_config_paths.h
> 
>  "$(OUTDIR)" :
>         @if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]


Re: Building psql.exe using the free Borland compiler

От
Mark Morgan Lloyd
Дата:
Bruce (et al.), sorry- I've only just spotted the activity. I've only got the
one version of the compiler, and since apart from Delphi I have very little
Windows development stuff set up (in particular I am not a C/C++ programmer, and
I'm trying to avoid Cygwin since it can mess up Lazarus) I've got limited scope
for tinkering.

I'll try and test the revised version as soon as I am able and will obviously
report back if there are problems- together with any fixes if I'm able to work
out what's going wrong.

I'd add here that I am indebted to a couple of more experienced C men on CIX for
a hint that enabled me to hack the _pclose problem, although there may be issues
relating to other versions of the compiler- that's one reason why I modified the
source rather than trying to fix things in the makefile.

Keep up the good work and hopefully I've been able to make some tiny
contribution :-)


Bruce Momjian wrote:
> 
> With no report back from markMLl, I have changed the BCC code to use ""
> rather than \"\".  Backpatched to 8.1.X.
> 
> ---------------------------------------------------------------------------
> 
> ljb wrote:
> > pgman@candle.pha.pa.us wrote:
> > >...
> > > As far as echo, I think you are right that the Win32 command processor
> > > is the one handling that, but I assumed the backslashes were handled by
> > > the Makefile, hence the need for \#.
> >
> > Sort of.  It looks to me like \# is handled by make when reading the
> > Makefile, resulting in a # which is not the start of a Makefile comment.
> > But it also seems that \ followed by anything else is not handled specially,
> > but simply passed through to the command.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]