cannot to compile extension by meson on windows

Started by Pavel Stehuleabout 1 year ago10 messages
#1Pavel Stehule
pavel.stehule@gmail.com

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

#2Andres Freund
andres@anarazel.de
In reply to: Pavel Stehule (#1)
Re: cannot to compile extension by meson on windows

Hi,

On 2024-12-01 18:52:48 +0100, Pavel Stehule wrote:

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

What windows build are you building against?

If it fails due to libintl you're likely missing the libintl headers that the
windows build was built against.

Greetings,

Andres Freund

#3Pavel Stehule
pavel.stehule@gmail.com
In reply to: Andres Freund (#2)
Re: cannot to compile extension by meson on windows

ne 1. 12. 2024 v 19:05 odesílatel Andres Freund <andres@anarazel.de> napsal:

Hi,

On 2024-12-01 18:52:48 +0100, Pavel Stehule wrote:

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

What windows build are you building against?

windows 11, msvc 2022

If it fails due to libintl you're likely missing the libintl headers that
the
windows build was built against.

This file is part of PostgreSQL's header files from the EDB installer. I
see this file there. I am able to build Orafce when I don't use meson.

Regards

Pavel

Show quoted text

Greetings,

Andres Freund

#4Andres Freund
andres@anarazel.de
In reply to: Pavel Stehule (#3)
Re: cannot to compile extension by meson on windows

Hi,

On 2024-12-01 19:11:05 +0100, Pavel Stehule wrote:

ne 1. 12. 2024 v 19:05 odes�latel Andres Freund <andres@anarazel.de> napsal:

If it fails due to libintl you're likely missing the libintl headers that
the
windows build was built against.

This file is part of PostgreSQL's header files from the EDB installer. I
see this file there. I am able to build Orafce when I don't use meson.

Then, presumably, your include paths don't include the relevant directory?

Greetings,

Andres Freund

#5Pavel Stehule
pavel.stehule@gmail.com
In reply to: Andres Freund (#4)
Re: cannot to compile extension by meson on windows

ne 1. 12. 2024 v 19:23 odesílatel Andres Freund <andres@anarazel.de> napsal:

Hi,

On 2024-12-01 19:11:05 +0100, Pavel Stehule wrote:

ne 1. 12. 2024 v 19:05 odesílatel Andres Freund <andres@anarazel.de>

napsal:

If it fails due to libintl you're likely missing the libintl headers

that

the
windows build was built against.

This file is part of PostgreSQL's header files from the EDB installer. I
see this file there. I am able to build Orafce when I don't use meson.

Then, presumably, your include paths don't include the relevant directory?

it is taken from pg_config.exe

On my linux computer, libintl is in /usr/include

On windows C:\Program Files\ PostgreSQL\16\include

So looks so definition

shared_module(
'orafce',
orafce_sources,
include_directories: [includedir_server],
install: true,
install_dir: pkglibdir,
name_prefix: '',
)

can works only on Linux

msvc requires

include_directories: [includedir_server / 'port/win32_msvc',
includedir_server / 'port/win32', includedir_server, includedir],

Another prerequisite is using x64 Native tools command line, but still I
have problem, because meson badly detects target cpu

Show quoted text

Greetings,

Andres Freund

#6Pavel Stehule
pavel.stehule@gmail.com
In reply to: Pavel Stehule (#5)
Re: cannot to compile extension by meson on windows

ne 1. 12. 2024 v 21:06 odesílatel Pavel Stehule <pavel.stehule@gmail.com>
napsal:

ne 1. 12. 2024 v 19:23 odesílatel Andres Freund <andres@anarazel.de>
napsal:

Hi,

On 2024-12-01 19:11:05 +0100, Pavel Stehule wrote:

ne 1. 12. 2024 v 19:05 odesílatel Andres Freund <andres@anarazel.de>

napsal:

If it fails due to libintl you're likely missing the libintl headers

that

the
windows build was built against.

This file is part of PostgreSQL's header files from the EDB installer. I
see this file there. I am able to build Orafce when I don't use meson.

Then, presumably, your include paths don't include the relevant directory?

it is taken from pg_config.exe

On my linux computer, libintl is in /usr/include

On windows C:\Program Files\ PostgreSQL\16\include

So looks so definition

shared_module(
'orafce',
orafce_sources,
include_directories: [includedir_server],
install: true,
install_dir: pkglibdir,
name_prefix: '',
)

can works only on Linux

msvc requires

include_directories: [includedir_server / 'port/win32_msvc',
includedir_server / 'port/win32', includedir_server, includedir],

Another prerequisite is using x64 Native tools command line, but still I
have problem, because meson badly detects target cpu

look like my problem - I had to use --wipe

now, I am playing with linking issues

Show quoted text

Greetings,

Andres Freund

#7Pavel Stehule
pavel.stehule@gmail.com
In reply to: Pavel Stehule (#6)
Re: cannot to compile extension by meson on windows

ne 1. 12. 2024 v 21:16 odesílatel Pavel Stehule <pavel.stehule@gmail.com>
napsal:

ne 1. 12. 2024 v 21:06 odesílatel Pavel Stehule <pavel.stehule@gmail.com>
napsal:

ne 1. 12. 2024 v 19:23 odesílatel Andres Freund <andres@anarazel.de>
napsal:

Hi,

On 2024-12-01 19:11:05 +0100, Pavel Stehule wrote:

ne 1. 12. 2024 v 19:05 odesílatel Andres Freund <andres@anarazel.de>

napsal:

If it fails due to libintl you're likely missing the libintl headers

that

the
windows build was built against.

This file is part of PostgreSQL's header files from the EDB installer.

I

see this file there. I am able to build Orafce when I don't use meson.

Then, presumably, your include paths don't include the relevant
directory?

it is taken from pg_config.exe

On my linux computer, libintl is in /usr/include

On windows C:\Program Files\ PostgreSQL\16\include

So looks so definition

shared_module(
'orafce',
orafce_sources,
include_directories: [includedir_server],
install: true,
install_dir: pkglibdir,
name_prefix: '',
)

can works only on Linux

msvc requires

include_directories: [includedir_server / 'port/win32_msvc',
includedir_server / 'port/win32', includedir_server, includedir],

Another prerequisite is using x64 Native tools command line, but still I
have problem, because meson badly detects target cpu

look like my problem - I had to use --wipe

now, I am playing with linking issues

with some changes I am able to build orafce on msvc by meson

https://github.com/orafce/orafce/blob/master/meson.build

Show quoted text

Greetings,

Andres Freund

#8Pavel Stehule
pavel.stehule@gmail.com
In reply to: Pavel Stehule (#7)
Re: cannot to compile extension by meson on windows

ne 1. 12. 2024 v 22:24 odesílatel Pavel Stehule <pavel.stehule@gmail.com>
napsal:

ne 1. 12. 2024 v 21:16 odesílatel Pavel Stehule <pavel.stehule@gmail.com>
napsal:

ne 1. 12. 2024 v 21:06 odesílatel Pavel Stehule <pavel.stehule@gmail.com>
napsal:

ne 1. 12. 2024 v 19:23 odesílatel Andres Freund <andres@anarazel.de>
napsal:

Hi,

On 2024-12-01 19:11:05 +0100, Pavel Stehule wrote:

ne 1. 12. 2024 v 19:05 odesílatel Andres Freund <andres@anarazel.de>

napsal:

If it fails due to libintl you're likely missing the libintl

headers that

the
windows build was built against.

This file is part of PostgreSQL's header files from the EDB

installer. I

see this file there. I am able to build Orafce when I don't use meson.

Then, presumably, your include paths don't include the relevant
directory?

it is taken from pg_config.exe

On my linux computer, libintl is in /usr/include

On windows C:\Program Files\ PostgreSQL\16\include

So looks so definition

shared_module(
'orafce',
orafce_sources,
include_directories: [includedir_server],
install: true,
install_dir: pkglibdir,
name_prefix: '',
)

can works only on Linux

msvc requires

include_directories: [includedir_server / 'port/win32_msvc',
includedir_server / 'port/win32', includedir_server, includedir],

Another prerequisite is using x64 Native tools command line, but still I
have problem, because meson badly detects target cpu

look like my problem - I had to use --wipe

now, I am playing with linking issues

with some changes I am able to build orafce on msvc by meson

https://github.com/orafce/orafce/blob/master/meson.build

and with some little bit of gaming and DiffUtil installation from
https://gnuwin32.sourceforge.net/packages/diffutils.htm
I am able to run regress tests - unexpected success for me.

Regards

Pavel

Show quoted text

Greetings,

Andres Freund

#9Vladlen Popolitov
v.popolitov@postgrespro.ru
In reply to: Pavel Stehule (#1)
Re: cannot to compile extension by meson on windows

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
/messages/by-id/TYVPR01MB1133078C93F9FE432CA466573E40E2@TYVPR01MB11330.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.

--
Best regards,

Vladlen Popolitov.

#10Pavel Stehule
pavel.stehule@gmail.com
In reply to: Vladlen Popolitov (#9)
Re: cannot to compile extension by meson on windows

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

/messages/by-id/TYVPR01MB1133078C93F9FE432CA466573E40E2@TYVPR01MB11330.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.

Show quoted text

--
Best regards,

Vladlen Popolitov.