Re: cannot to compile extension by meson on windows - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: cannot to compile extension by meson on windows
Date
Msg-id CAFj8pRD7+peh=RF3Y1k7XzcS-3_pQjNa0xktSf9sX89ewFU4LQ@mail.gmail.com
Whole thread Raw
In response to Re: cannot to compile extension by meson on windows  (Vladlen Popolitov <v.popolitov@postgrespro.ru>)
List pgsql-hackers


pá 27. 12. 2024 v 9:50 odesílatel Vladlen Popolitov <v.popolitov@postgrespro.ru> napsal:
Pavel Stehule писал(а) 2024-12-01 20:52:
> Hi
>
> Did somebody test compilation of any extension on the WIN platform by
> using meson?
>
> I prepared meson.build
> https://github.com/orafce/orafce/blob/master/meson.build
>
> I tested it successfully on Linux.
>
> But it fails on Windows - a lot of compilation fails on missing
> libintl.h
>
> DOCDIR = C:/PROGRA~1/POSTGR~1/16/doc
> HTMLDIR = C:/PROGRA~1/POSTGR~1/16/doc
> INCLUDEDIR = C:/PROGRA~1/POSTGR~1/16/include
> PKGINCLUDEDIR = C:/PROGRA~1/POSTGR~1/16/include
> INCLUDEDIR-SERVER = C:/PROGRA~1/POSTGR~1/16/include/server`
>
> looks so msvc cannot work with just this configuration.
>
> I can compile orafce when I use setup described by
> https://github.com/orafce/orafce/blob/master/README.msvc
>
> Regards
>
> Pavel

Hi!

  In other thread
https://www.postgresql.org/message-id/TYVPR01MB1133078C93F9FE432CA466573E40E2%40TYVPR01MB11330.jpnprd01.prod.outlook.com
Kohei Harikae makes good work to clarify meson documentation, especially
regarding additional libraries.

I suppose in your case meson did not found gettext library, libintl.h
from this library.

You can:
1) install gettext, f.e by vcpkg package manager:
vcpkg.exe install gettext:x64-windows
--x-install-root=c:\postgres\gettext

2) You could add gettext .pc file directory to PKG_CONFIG_PATH ( ;
separated list, meson uses configarations in this order
SET
PKG_CONFIG_PATH=c:\postgres\gettext\x64-windows\lib\pkgconfig;%PKG_CONFIG_PATH%
but this file is not created for this library (you can create it by
yourself, but exists other solution - in step 4)
3) make all other steps to run meson, f.e. call "C:\Program
Files\Microsoft Visual
Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64

4) run meson setup with option -Dnls=enabled - it enables national
languages and uses gettext.
And you have to add options for gettext libraries and includes
directories:
meson setup c:\builddir -Dnsl=enabled

-Dextra_include_dirs=c:\postgres\gettext\x64-windows\include,c:\otherlibs\include
  -Dextra_lib_dirs=c:\postgres\gettext\x64-windows\lib,c:\otherlibs\lib
...other options...

extra_include_dirs and extra_lib_dirs are options defined by PostgreSQL.
This options are
comma separated lists of directories, if every value does not contain
comma itself (if contains, it better
to read meson get_options() documentation, it is not easy to explain
shortly meson language syntax).

meson using PKG_CONFIG_PATH detects all library and makes all work with
include and lib paths,
but if library does not have .pc file, you can define paths in options.

If you build with -Dnlas=enabled, you have to be careful with tests.
Tests in this case run
with the default system language, and some tests will fail, as they are
check log files output
and compare it with English answers.

I hope this helps you.

Thank you for the interesting information. I compiled extensions already. Maybe the problem is in pg_config

if meson.get_compiler('c').get_id() == 'msvc'
  incdir = [includedir_server / 'port/win32_msvc',
            includedir_server / 'port/win32',
            includedir_server,
            includedir]
  postgres_lib = meson.get_compiler('c').find_library(
                                           'postgres',
                                            dirs: libdir,
                                            static: true,
                                            required: true
                                         )
else
  incdir = [ includedir_server ]
  postgres_lib = ''
endif

looks so returned include dir is not enough for successful compilation, and there should be some extra magic.
Maybe pg_config doesn't support specific msvc configuration.



 

--
Best regards,

Vladlen Popolitov.

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: FileFallocate misbehaving on XFS
Next
From: Bruce Momjian
Date:
Subject: Re: [PATCHES] Post-special page storage TDE support