Thread: gettext instructions for Windows seems wrong

gettext instructions for Windows seems wrong

From
PG Doc comments form
Date:
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/install-windows-full.html
Description:

I have to build Postgres on Windows 10. I got everything building from a git
checkout without NLS. I followed the instructions the way I understood them
(possibly incorrectly).

To add NLS support, I read this:
Gettext is required to build with NLS support, and can be downloaded from
http://gnuwin32.sourceforge.net. Note that binaries, dependencies and
developer files are all needed.

So, I went to that site and downloaded the binaries, dependencies, and
developer files as three separate ZIPs. I created a folder,
C:\Users\Documents\Code\libintl and then extracted all three ZIPs into that
directory. In that folder, there end up being directories for: bin, contrib,
include, lib, man, manifest, share. This makes sense to me; all the
extracted files are merged into one coherent directory tree rooted at
C:\Users\Documents\Code\libintl.

The instructions say that I have to edit config.pl (actually, I had to
create it), and I added this line:
$config->{nls} = 'C:\Users\dcbow\Documents\Code\libintl';

Then when I run "build", I get:

fe-misc.obj : error LNK2019: unresolved external symbol
__imp_libintl_dgettext referenced in function libpq_gettext
[c:\Users\dcbow\Documents\Code\postgres\libpq.vcxproj]
fe-misc.obj : error LNK2019: unresolved external symbol
__imp_libintl_dngettext referenced in function libpq_ngettext
[c:\Users\dcbow\Documents\Code\postgres\libpq.vcxproj]
fe-misc.obj : error LNK2019: unresolved external symbol
__imp_libintl_bindtextdomain referenced in function libpq_binddomain
[c:\Users\dcbow\Documents\Code\postgres\libpq.vcxproj]
libpgport.lib(strerror.obj) : error LNK2019: unresolved external symbol
__imp_libintl_gettext referenced in function pg_strerror_r
[c:\Users\dcbow\Documents\Code\postgres\libpq.vcxproj]
libpgport.lib(chklocale.obj) : error LNK2001: unresolved external symbol
__imp_libintl_gettext
[c:\Users\dcbow\Documents\Code\postgres\libpq.vcxproj]
C:\Users\dcbow\Documents\Code\libintl\lib\libintl.lib : warning LNK4272:
library machine type 'x86' conflicts with target machine type 'x64'
[c:\Users\dcbow\Documents\Code\postgres\libpq.vcxproj]
.\Debug\libpq\libpq.dll : fatal error LNK1120: 4 unresolved externals
[c:\Users\dcbow\Documents\Code\postgres\libpq.vcxproj]

Based on the line containing LNK4272, I learned two things here: 1. It seems
like extracting the files that I did in the place that I did and also
setting the line in config.pl that I did all seem right; at least the build
can find the files. 2. It's 32 bit, not 64, which seems to create another
problem. The documentation says: "To use a server-side third party library
such as python or OpenSSL, this library must also be 64-bit. There is no
support for loading a 32-bit library in a 64-bit server. "

I'm trying to build this, rather than use the installer,  in order to find
whatever commit introduced a particular bug in libpq. I downloaded the
binary (ZIP) files from EnterpriseDB at
https://www.enterprisedb.com/download-postgresql-binaries, and they include
libintl-9.dll. In fact, in at least 12.9, 13.5 and 14.1, it's the exact same
binary. But the libintl DLL that's in http://gnuwin32.sourceforge.net/ is
named libintl3.dll and was built 17 years ago.

So, my chief complaint is that the gettext/libintl download that's listed in
the documentation is a creaky antique that, due to API changes and bitness
issues in the given build, will not work. I'm investigating
https://mlocati.github.io/articles/gettext-iconv-windows.html, which are
just more modern builds, or building all of it myself with MSYS2.

Any guidance would be appreciated, as would some sort of update to the docs
that do not have such an outdated dependency reference. Thanks for such
otherwise excellent documentation!

Re: gettext instructions for Windows seems wrong

From
Daniel Gustafsson
Date:
> On 17 Jan 2022, at 23:55, PG Doc comments form <noreply@postgresql.org> wrote:

> The instructions say that I have to edit config.pl (actually, I had to
> create it)..

I know next to nothing about NLS on Windows, but regardless of doc updates for
this I think we should clarify that config.pl may not exist, like how we do for
buildenv.pl.

--
Daniel Gustafsson        https://vmware.com/




Re: gettext instructions for Windows seems wrong

From
Bruce Momjian
Date:
On Wed, Jan 19, 2022 at 10:24:57AM +0100, Daniel Gustafsson wrote:
> > On 17 Jan 2022, at 23:55, PG Doc comments form <noreply@postgresql.org> wrote:
> 
> > The instructions say that I have to edit config.pl (actually, I had to
> > create it)..
> 
> I know next to nothing about NLS on Windows, but regardless of doc updates for
> this I think we should clarify that config.pl may not exist, like how we do for
> buildenv.pl.

Good point --- I have developed the attached patch to implement this.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  Indecision is a decision.  Inaction is an action.  Mark Batterson


Attachment

Re: gettext instructions for Windows seems wrong

From
Julien Rouhaud
Date:
Hi,

On Fri, Jul 22, 2022 at 10:32:42AM -0400, Bruce Momjian wrote:
> On Wed, Jan 19, 2022 at 10:24:57AM +0100, Daniel Gustafsson wrote:
> > > On 17 Jan 2022, at 23:55, PG Doc comments form <noreply@postgresql.org> wrote:
> >
> > > The instructions say that I have to edit config.pl (actually, I had to
> > > create it)..
> >
> > I know next to nothing about NLS on Windows, but regardless of doc updates for
> > this I think we should clarify that config.pl may not exist, like how we do for
> > buildenv.pl.
>
> Good point --- I have developed the attached patch to implement this.

+1, I remember I also got confused by it for a minute the first time I tried to
manually build postgres on Windows.

Patch LGTM.



Re: gettext instructions for Windows seems wrong

From
Daniel Gustafsson
Date:
> On 22 Jul 2022, at 16:32, Bruce Momjian <bruce@momjian.us> wrote:
>
> On Wed, Jan 19, 2022 at 10:24:57AM +0100, Daniel Gustafsson wrote:
>>> On 17 Jan 2022, at 23:55, PG Doc comments form <noreply@postgresql.org> wrote:
>>
>>> The instructions say that I have to edit config.pl (actually, I had to
>>> create it)..
>>
>> I know next to nothing about NLS on Windows, but regardless of doc updates for
>> this I think we should clarify that config.pl may not exist, like how we do for
>> buildenv.pl.
>
> Good point --- I have developed the attached patch to implement this.

Thanks, LGTM

--
Daniel Gustafsson        https://vmware.com/




Re: gettext instructions for Windows seems wrong

From
Bruce Momjian
Date:
On Fri, Jul 22, 2022 at 10:32:42AM -0400, Bruce Momjian wrote:
> On Wed, Jan 19, 2022 at 10:24:57AM +0100, Daniel Gustafsson wrote:
> > > On 17 Jan 2022, at 23:55, PG Doc comments form <noreply@postgresql.org> wrote:
> > 
> > > The instructions say that I have to edit config.pl (actually, I had to
> > > create it)..
> > 
> > I know next to nothing about NLS on Windows, but regardless of doc updates for
> > this I think we should clarify that config.pl may not exist, like how we do for
> > buildenv.pl.
> 
> Good point --- I have developed the attached patch to implement this.

Patch applied back to PG 10.  Thanks for the report.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  Indecision is a decision.  Inaction is an action.  Mark Batterson