Open marin-m opened 2 years ago
Hi! Can you build GNU gettext itself in this environment, without using the crate? (I'm trying to understand if the problem is with GNU gettext itself, or just with our build.rs).
Unfortunately, we don't have any Windows experts watching this crate, so the Windows support is pretty weak (see #12).
Just an hypothesis, may it be linked to the lack of passing the expected --host
argument to the ./configure
script of GNU gettext?
gettext-0.21/libtextstyle/lib/Makefile.am
contains a line which explicitly states that the declaration of the iastty
function present in the isatty.c
file of libtextstyle
should explicitly be turned into a declaration of libtextstyle_isatty
when the @host_os@
variable (if I understand well, the third component of the --host
parameter) starts with mingw
:
case "@host_os@" in \
mingw*) echo '#define isatty libtextstyle_isatty' ;; \
On the other hand, this warning is emitted multiple times in the visible output of cargo
, at the moment where libtextstyle
is build:
configure: WARNING: using cross tools not prefixed with host triplet
configure: WARNING: using cross tools not prefixed with host triplet
configure: WARNING: using cross tools not prefixed with host triplet
configure: WARNING: using cross tools not prefixed with host triplet
Sounds plausible. I admit I never cross-compiled anything in my life, so I can't really give any advice here :) If you unpack the tarball that we ship as part of gettext-sys, and run configure
with --host
, does that fix the problem?
It seems that I can also find this in the output of cargo
:
TARGET = Some("x86_64-pc-windows-gnu")
HOST = Some("x86_64-unknown-linux-gnu")
And that the condition that leads to using the libtextstyle_isatty
function assuming that it has been declared is fairly simple, but different from the host
check performed by the Makefile:
#if defined _WIN32 && ! defined __CYGWIN__
# include <io.h>
# ifdef __cplusplus
extern "C" {
# endif
extern int libtextstyle_isatty (int fd);
# undef isatty
# define isatty libtextstyle_isatty
So I think that the declaration code is interpreted from the Makefile when "compiling on native Windows with MinGW", while the reference code is interpreted from the C header when "compiling for Windows with anything that is not Cygwin".
I think that adapting the build.rs
for adapting the --host
to have the third element of the triplet contain mingw
when consequent may be a solution to try.
It looks like this latest solution doesn't suffice, when trying this gettext
will attempt to pass Windows tooling-specific flags disabling the odds of effective compilation.
libtool: error: unrecognised option: '-DPACKAGE_VERSION_STRING=\"0.21\"'
make[5]: *** [Makefile:2104 : libintl.res.lo] Erreur 1
make[5]: *** Attente des tâches non terminées....
Maybe that simply not building the gettext
examples (including hello.c
) would work out better.
Maybe that simply not building the gettext examples (including hello.c) would work out better.
Oh :sweat_smile: Indeed, we only need libraries, so if disabling the examples helps, then it's an acceptable solution.
I got a few steps further. I removed the references to the libtextstyle/adhoc-tests/
directory in the libtextstyle/*
build files and then I removed a few occurrences of a -lc
compilation flag present in the build files of gettext-tools/
that prevented to cross-compile to MinGW on Linux (the issue was the same, a configure
directive meant to suppress this flag from the compilation command on certain platforms was present but it seems that it activated only when MinGW was the host platform, not just the target).
I also recompressed the gettext-0.21.tar.xz
with the modified files using tar Jcvf
, obviously.
But not I obtain an error telling that I can't compile on my system (Ubuntu 20.04 LTS) because it has automake
1.16.1 installed and that the configuration scripts require automake
1.16.2:
configure.ac:25: error: version mismatch. This is Automake 1.16.1,
configure.ac:25: but the definition used by this AM_INIT_AUTOMAKE
configure.ac:25: comes from Automake 1.16.2. You should recreate
configure.ac:25: aclocal.m4 with aclocal and run automake again.
WARNING: 'automake-1.16' is probably too old.
You should only need it if you modified 'Makefile.am' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'automake' program is part of the GNU Automake package:
<https://www.gnu.org/software/automake>
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
<https://www.gnu.org/software/autoconf>
<https://www.gnu.org/software/m4/>
<https://www.perl.org/>
make[4]: *** [Makefile:2962 : /tmp/t33d84b-0/gettext/gettext-tools/src/Makefile.in] Erreur 63
make[3]: *** [Makefile:2355 : all-recursive] Erreur 1
make[2]: *** [Makefile:2223 : all] Erreur 2
make[1]: *** [Makefile:403 : all-recursive] Erreur 1
make: *** [Makefile:359 : all] Erreur 2
thread 'main' panicked at '
command did not execute successfully, got: exit code: 2
build script failed, must exit now', gettext-sys/build.rs:305:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Indeed:
$ apt search ^automake
En train de trier... Fait
Recherche en texte intégral... Fait
automake/focal,focal,now 1:1.16.1-4ubuntu6 all [installé]
outil de création de « Makefile » conformes aux standards GNU
I don't quite understand, is building for certain platforms restricted to having a rolling-release distribution?
Is this due to the choice of dynamically building the library using ./configure
rather than ./autogen.sh
?
Anyway my main intent when using gettext-rs
was to internationalize a gtk-rs
-based app, which works on Linux, I guess because the Rust binary is linked with the same gettext
library as GTK+/GtkBuilder, I also guess that this is not likely to work on Windows if building this crate on Windows implies building its own gettext
library for static linking contrary to Linux?
I also tried cross-compiling while enabling the gettext-system
feature of the crate:
gettext-sys = { version = "0.21.0", features = ["gettext-system"] }
gettext-rs = { version = "0.7.0" }
Using the same build commands as indicated in my first comment:
cd ~/rust-project/
export PKG_CONFIG_ALLOW_CROSS=1
export RUSTFLAGS="-L /opt/gtkwin/usr/x86_64-w64-mingw32/sys-root/mingw/lib"
export MINGW_PREFIX=/opt/gtkwin/usr/x86_64-w64-mingw32
export PKG_CONFIG_PATH=/opt/gtkwin/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig
cargo build --target x86_64-pc-windows-gnu --release
Using a cross-compiled libintl
/gettext
taken from Fedora packages, just like I did for obtaining the GTK+ packages required for building gtk-rs
:
$ find /opt/gtkwin/ -iname '*libintl*'
/opt/gtkwin/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libintl-8.dll
/opt/gtkwin/usr/x86_64-w64-mingw32/sys-root/mingw/lib/libintl.dll.a
/opt/gtkwin/usr/x86_64-w64-mingw32/sys-root/mingw/include/libintl.h
But it doesn't link:
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
|
= note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/rsbegin.o" "-L" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.0.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.1.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.10.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.11.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.12.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.13.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.14.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.15.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.2.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.3.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.4.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.5.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.6.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.7.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.8.rcgu.o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.9.rcgu.o" "-o" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.exe" "-Wl,--subsystem" "-Wl,windows" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.23xe9n6msx7dzmmm.rcgu.o" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps" "-L" "/home/marin/rust-project/target/release/deps" "-L" "/opt/gtkwin/usr/x86_64-w64-mingw32/sys-root/mingw/lib" "-L" "/home/marin/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib" "-L" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib" "-L" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib" "-L" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib" "-L" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib" "-L" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib" "-L" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib" "-L" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib" "-L" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib" "-L" "/opt/gtkwin/usr/x86_64-w64-mingw32/lib" "-L" "/opt/gtkwin/usr/x86_64-w64-mingw32/../usr/lib" "-L" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib" "-L" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib" "-L" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/build/minimp3-sys-4ab3cefb91bc1ecf/out" "-L" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib" "-Wl,-Bstatic" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libbase64-f6aec37606329f32.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libtempfile-3c6b179a11845d56.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/librand-4816512bf2009244.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/librand_chacha-1dc40961670e70e9.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/librand_core-f95a9d25e4e84aa1.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libremove_dir_all-55bd5a97c849fae4.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/librodio-886ab00e24f60085.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libhound-2009a117d0d90e18.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/liblewton-eae6042f93939d49.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libogg-06f698dc416b5ebb.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libminimp3-9b06490f67a18209.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libslice_deque-3fba908b3e21f788.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libminimp3_sys-f79b00068bd6df3b.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libclaxon-c0e3b6d778c37552.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libcsv-c71ae16d3f236b71.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libcsv_core-6df0146cec8a3766.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libbstr-414a97bfcf2497b3.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libregex_automata-dffddca9aa2cde42.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libclap-08673ac17bd4434e.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libvec_map-33b9308c26671138.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libtextwrap-cfdf5060a97a65c4.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libunicode_width-ff3526b59f89b45c.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libstrsim-6f28df9ed39ec34a.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libatty-716a1e9308b97f1c.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libapp_dirs-4610bdd8a16bbcca.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libshell32-ed2d0a779788df27.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libole32-989bdf8f6aa324a3.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libcpal-b8ed5b8e9b05184b.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libchrono-3ecfadcc1bd91a57.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libnum_integer-987d10b1bb958c47.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libtime-149227d01af50685.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libgtk-2467b6b95432671f.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libgdk-a69cad50aad3b44d.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libpango-ae61e308d3f3a32f.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libgdk_pixbuf-78d6e6244cf37839.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libcairo-c8e761f96ea60cbe.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libatk-1dde512b5124b6e9.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libgtk_sys-e7ac79b73663039e.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libatk_sys-c02142fa6cf84526.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libgdk_sys-5e44bdf38b41fcf6.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libpango_sys-4a75dfb5f418a216.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libgdk_pixbuf_sys-9afe23287abb1a86.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libcairo_sys-e7e41ce1eef74b9f.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libgio-f455caf5af82479c.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libfutures-594daad337a23401.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libthiserror-558b8898b5a614fb.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libgio_sys-6a980c27e0e11bf6.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libglib-6e9d8918107eab20.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libfutures_executor-7da68945df9b54f5.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libgobject_sys-afc18134732913d2.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libglib_sys-3791bd99e908dd93.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/liblibc-893a1678759f7915.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libbitflags-b3d5f61258991341.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libcrc32fast-464618bf441ed0d8.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libbyteorder-187852a3bec662c2.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libchfft-3e0603fa05a1b66f.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libnum_complex-417473de0e557744.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libnum_traits-a6b9422194b9ca27.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libuuid-fd6fb09067a25185.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libgetrandom-69398bc97034d793.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/librand-efff2da3dcda547e.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/librand_chacha-f9127bc4a9bebcbd.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libppv_lite86-4aecc54cbeedac65.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/librand_core-3567952a30c69ef2.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libgetrandom-6c63956209f684e7.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libreqwest-6dba7bee8701b0ab.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libhyper_tls-3143f6ce972cdb99.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libwinreg-c966c4d3d165d651.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libipnet-8d3dc7e66b9cf20e.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libtokio_tls-52b5b72a8550f98b.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libserde_urlencoded-406ee2729557d362.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libencoding_rs-2daa1aa979a3667a.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libbase64-114c89239198e14b.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libmime_guess-5c6aa890b9175df8.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libunicase-5cc467a83130c0eb.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libmime-44b4921bc23a3892.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libnative_tls-f4c77b82657bdf07.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libschannel-4012e8668a18114c.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libhyper-a0b728b8281af60f.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libhttparse-4f088fc0565d0eda.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libwant-9da61ae9418b0308.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libtry_lock-3ff0fa52a8fd2be0.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libh2-9abcef0bbc004e27.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libtracing_futures-24cb3179042bd9bc.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libpin_project-e42e1e89cc66d6d6.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libindexmap-be57c4e88dff8dd3.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libhashbrown-c3173b916b2ec968.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libtokio_util-fc4c59171e34b6a3.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libhttpdate-8907bcb83ffad6cb.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libsocket2-5bc965a2d566b246.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libtower_service-c540fa87fbca51f9.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libpin_project-1d69bbc8cd6b412c.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libtracing-c17f6335e327836d.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libtracing_core-d3cace0313380109.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libtokio-ad4b4a3afb07070d.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libnum_cpus-ec5233e1badd2f8f.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libmio-2af0b0b6fe4f03a0.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libmiow-eff245df74adaf4e.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libws2_32-a17aaf3737efc251.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libkernel32-dbbde393e49c8985.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libwinapi-29ee4562ae901a53.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libiovec-5b4cbd56cf2284f8.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libnet2-fa3e18f58ca60128.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libcfg_if-89e2f6ff1a89fe23.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libpin_project_lite-c57b8f63eed68ea1.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libhttp_body-3f920db743dca049.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libbytes-753f9311a3ba3a3a.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/liblog-8ab02f53a71b88ac.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libcfg_if-b4211b99a2401361.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libfutures_util-4c8707c98b542040.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libfutures_io-ce0d1178c59000f7.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libslab-3fe2d8bbd6092463.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libfutures_channel-fa42cdf41862b025.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libpin_project_lite-9c61cd1565121764.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libfutures_sink-189d740cf3263762.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libfutures_task-663fe4cde844a8e7.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libpin_utils-e88c665a22653821.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libfutures_core-8f969e7f88fd92b6.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/liburl-2c9bb288da87539d.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libidna-3441efbe74e46f9b.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libunicode_normalization-4f579406913a97a5.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libtinyvec-58bafa873195834a.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libtinyvec_macros-08f439e9da7d9007.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libunicode_bidi-a3344e5a375029b7.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libform_urlencoded-b898f352232fe249.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libpercent_encoding-1f98f11c6c17e9e9.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libmatches-b537973cf9d05c7a.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libhttp-05a4b29ea4de2956.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libbytes-9e19899b9d1dd027.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libfnv-d7a163b66e943376.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libserde_json-4edac14fce9371a2.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libryu-527f30756d7dc630.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libitoa-2b590f7def3f6249.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libserde-f21598906ef2c9bb.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libgettextrs-29e78085df54db97.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libgettext_sys-36cc826f488cbef3.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/liblocale_config-5cf0b96f6f0bdc5b.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libwinapi-c338e5b1f9310db8.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libregex-9a32979c26b63072.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libthread_local-e51185af9fbfa72e.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libonce_cell-b4e1b434e801f8ec.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libregex_syntax-0b37404a7958bec8.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libaho_corasick-61a0fd1c731e6ff8.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/libmemchr-d637443ff5479ede.rlib" "/home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/liblazy_static-03939b1541e24689.rlib" "-Wl,--start-group" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libstd-b3e05fb1c668425d.rlib" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libpanic_unwind-de6b1e1839bc55c3.rlib" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libobject-d462ba5d23db4375.rlib" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libaddr2line-91f359062fcc4faa.rlib" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libgimli-1285b73e96b90384.rlib" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/librustc_demangle-2e399a6f31e1ac65.rlib" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libhashbrown-cdd2f8d624f05ca0.rlib" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/librustc_std_workspace_alloc-dfacd2ffb7ac7d0f.rlib" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libunwind-113950dd2d010a25.rlib" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libcfg_if-acaab9dfbd2da45f.rlib" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/liblibc-c8a337935bf5603e.rlib" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/liballoc-e81d86989503275b.rlib" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/librustc_std_workspace_core-037111c82a639dfe.rlib" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libcore-78a80358c99fdc57.rlib" "-Wl,--end-group" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libcompiler_builtins-ae4f14151f891fbb.rlib" "-Wl,-Bdynamic" "-lshell32" "-lole32" "-lgtk-3" "-lgdk-3" "-lgdi32" "-limm32" "-lshell32" "-lole32" "-lwinmm" "-ldwmapi" "-lsetupapi" "-lcfgmgr32" "-lpangowin32-1.0" "-lpangocairo-1.0" "-lpango-1.0" "-lharfbuzz" "-latk-1.0" "-lcairo-gobject" "-lcairo" "-lgdk_pixbuf-2.0" "-lgio-2.0" "-lgobject-2.0" "-lglib-2.0" "-lintl" "-latk-1.0" "-lgobject-2.0" "-lglib-2.0" "-lintl" "-lgdk-3" "-lgdi32" "-limm32" "-lshell32" "-lole32" "-lwinmm" "-ldwmapi" "-lsetupapi" "-lcfgmgr32" "-lpangowin32-1.0" "-lpangocairo-1.0" "-lpango-1.0" "-lharfbuzz" "-lgdk_pixbuf-2.0" "-lcairo-gobject" "-lcairo" "-lgobject-2.0" "-lglib-2.0" "-lintl" "-lpango-1.0" "-lgobject-2.0" "-lglib-2.0" "-lintl" "-lharfbuzz" "-lgdk_pixbuf-2.0" "-lgobject-2.0" "-lglib-2.0" "-lintl" "-lcairo-gobject" "-lcairo" "-lgobject-2.0" "-lglib-2.0" "-lintl" "-lgio-2.0" "-lgobject-2.0" "-lglib-2.0" "-lintl" "-lgobject-2.0" "-lglib-2.0" "-lintl" "-lglib-2.0" "-lintl" "-lbcrypt" "-ladvapi32" "-lws2_32" "-lkernel32" "-lintl" "-lpthread" "-lwinapi_advapi32" "-lwinapi_bcrypt" "-lwinapi_cfgmgr32" "-lwinapi_credui" "-lwinapi_crypt32" "-lwinapi_cryptnet" "-lwinapi_fwpuclnt" "-lwinapi_gdi32" "-lwinapi_kernel32" "-lwinapi_mmdevapi" "-lwinapi_msimg32" "-lwinapi_ncrypt" "-lwinapi_ntdll" "-lwinapi_ole32" "-lwinapi_opengl32" "-lwinapi_secur32" "-lwinapi_synchronization" "-lwinapi_user32" "-lwinapi_winspool" "-lwinapi_ws2_32" "-ladvapi32" "-lws2_32" "-luserenv" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "/home/marin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/rsend.o"
= note: /usr/bin/x86_64-w64-mingw32-ld: /home/marin/rust-project/target/x86_64-pc-windows-gnu/release/deps/songrec-02b5f1bcaaabb653.songrec.1jxrt9h1-cgu.12.rcgu.o:songrec.1jxrt9h1-c:(.text+0xb2b0): undefined reference to `wbindtextdomain'
collect2: error: ld returned 1 exit status
I admit I never cross-compiled anything in my life
If you are willing to reproduce the concerned environment, all the commands and cargo
flags that I used to setup and use the cross-compiling environment are present in the initial message of the issue, I'm not using more. Except this for downloading more MinGW dependencies into /opt/gtkwin
, most of which are unrelated to this crate:
for pkg in mingw64-gtk3-3.24.23-1 mingw64-pango-1.44.7-3 mingw64-cairo-1.16.0-4 mingw64-harfbuzz-2.6.8-2 mingw64-glib2-2.64.3-2 mingw64-gdk-pixbuf-2.40.0-3 mingw64-atk-2.36.0-3 mingw64-harfbuzz-2.6.8-2 mingw64-libpng-1.6.37-4 mingw64-pixman-0.40.0-2 mingw64-pcre-8.43-4 mingw64-libffi-3.1-10 mingw64-libepoxy-1.5.4-3 mingw64-fribidi-1.0.10-2 mingw64-libjpeg-turbo-2.0.5-2 mingw64-libtiff-4.0.9-7 mingw64-freetype-2.10.2-2 mingw64-fontconfig-2.13.1-4 mingw64-expat-2.2.8-3 mingw64-librsvg2-2.40.19-8 mingw64-gtk-update-icon-cache-3.24.23-1 mingw64-adwaita-icon-theme-3.36.1-2 mingw64-hicolor-icon-theme-0.17-3 mingw64-bzip2-1.0.8-3; do
wget https://download-ib01.fedoraproject.org/pub/fedora/linux/releases/33/Everything/x86_64/os/Packages/m/${pkg}.fc33.noarch.rpm
rpm2cpio ${pkg}.fc33.noarch.rpm | cpio -idmv
done
Cross-compiling is a lot about using another toolchain gcc
, ld
, etc. binaries, library files and paths instead of your system's defaults, not much more from an user point of view.
Is this due to the choice of dynamically building the library using ./configure rather than ./autogen.sh?
Most probably. Unfortunately, ./autogen.sh requires autotools and downloads files from the Internet, so I don't think it's a good idea to run it automatically on every user's machine. To get around this limitation, you can build GNU gettext separately and use this crate's environment variables to use your build from Rust.
building this crate on Windows implies building its own gettext library for static linking contrary to Linux?
You can set GETTEXT_SYSTEM
env var or gettext-system
Cargo feature to use the library you already have installed. This works on Linux and Windows alike. (At least, it works on Linux and should work on Windows.)
If you are willing to reproduce the concerned environment,
Can't do right now, sorry.
Thank you for your answers.
Unfortunately, ./autogen.sh requires autotools and downloads files from the Internet, so I don't think it's a good idea to run it automatically on every user's machine. To get around this limitation, you can build GNU gettext separately and use this crate's environment variables to use your build from Rust.
If I understand well, the automated gettext
build process will succeed running only on systems having a fixed minor version of automake
installed, not provide dynamic binding and integration with external GUI libraries due to functions being static, and all this not considering the other things such as the hardcoded tar
command.
Should it then not be an opt-in feature to attempt to build gettext
using the current build script, rather than an opt-out feature through the gettext-system
option as currently? Indeed, I think that people are way more used to be expected to install their dependent libraries themselves on their system (on UNIX/Linux) or to have the .DLL files at the right place (on Windows) than having things ending up working because they were in the exact same system setup as the author of the library.
The automated build process requires a certain minimum version of automake, and works fine with newer ones (like 1.16.3 from Debian testing). You should really bring this upstream; I'm not maintaining GNU gettext and can't provide justifications for their choices. The rest of your description is spot on.
For whatever reason, opt-out is the norm for the -sys
crates. Most of the time, users are unaware of it because most libraries can be detected via pkg-config
; the crate uses the system library if it can find it. GNU gettext doesn't support pkg-config
, so we can't detect its presence, and have to build the library ourselves.
I guess the idea is that at least for some users, cargo build
just works with no additional effort. Over time, as we improve our build.rs, cargo build
works for bigger and bigger fraction of the user base. In the meantime, users for whom it doesn't work, or those who want to use a different build, can still use gettext-system
and make it all work (albeit with extra effort).
So I understand where you are coming from, but I think the opt-out is going to stay.
For whatever reason, opt-out is the norm for the
-sys
crates.
Most libraries don't need to have a global heap context shared between the process-wide users of the library like gettext
does. This context will be shared, for example, between the Rust code of the program and the GTK+ Glade or, supposedly, Qt Designer, or another framework that will parse the strings to translate from an external resource file rather than from the Rust source code. And as GUI programs are way more likely to often use gettext
compared to CLI programs, that's why I think that it shouldn't be treated like "most libraries" or attempt to be statically compiled by default at all.
The incompatibilities related with pkg-config
and automake
are the other reasons.
Most libraries don't need to have a global heap context shared between the process-wide users of the library like gettext does.
Okay, you convinced me! Making gettext-system
opt-out will also give users an extra opportunity to learn that GNU gettext is released under LGPL, and linking it statically means the user has to abide by the relevant LGPL sections. I filed #84 for this.
Is the original problem of this issue resolved by #79? Can this be closed now?
I filed #84 for this.
Thanks!
Is the original problem of this issue resolved by #79? Can this be closed now?
Pull request #79 addressed an issue in dynamically linking the library with an externally obtained copy of GNU Gettext on MinGW.
This issue (#76) is about auto cross-compiling a whole static GNU Gettext using build.rs
for MinGW.
I can confirm the specific issue pointed by issue #79 (which is then another issue) was addressed by my pull request, as compiling succeeds when using the latest Git version:
gettext-sys = { git = "https://github.com/Koka/gettext-rs", commit = "4549250", features = ["gettext-system"] }
gettext-rs = { git = "https://github.com/Koka/gettext-rs", commit = "4549250" }
Ah, I see — I got confused by all the other problems you discovered :) Did you get a chance to try suggestions from my first and second comments?
I just tried to compile GNU gettext without examples, but it appears there's no configure
switch for that, and Makefiles are all recursive, so there's no chance of doing something like make libgettext.a
unfortunately.
Hello,
Hi! Can you build GNU gettext itself in this environment, without using the crate?
Linux-compiling the GNU Gettext package from the crate's tarball works without modification it seems.
Cross-compiling the GNU Gettext package from the crate's tarball for MinGW triggers the different issues mentioned above (at least 3 issues IIRC).
If you unpack the tarball that we ship as part of gettext-sys, and run configure with --host, does that fix the problem?
It does not work, the build script tries to do things which I think are specific to a real Windows environment, or maybe are just broken, see: https://github.com/Koka/gettext-rs/issues/76#issuecomment-894421103
Okay, please talk to the upstream then. (Maybe look at their INSTALL and INSTALL.windows docs first). Once you've figured out how to build it manually, we can talk on how to teach build.rs
to do the same tricks.
I can reproduce the issue using the gtk+meson+rust template here : https://gitlab.gnome.org/bilelmoussaoui/gtk-rust-template
I installed Rustup using the official tools on my x64 windows and tried to build the project using the mingw64 shell… but no luck.
= note: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/home/Moi/squirrel-gtk/_build/target\release\deps\squirrel-704f4ed6fa278aae.squirrel.85bdbfb4-cgu.12.rcgu.o:squirrel.85bdbfb4-:(.text+0x503): undefined reference to `wbindtextdomain'
same issue when I link rust+gtk+-3.0 application as following under window 10 OS gettext-rs-0.7.0\src/lib.rs:382: undefined reference to `wbindtextdomain' collect2.exe: error: ld returned 1 exit status
Hello,
When trying to build a Rust project which is using
gettext-rs
, using either the latest stable version of the library or the latest Git hash:or
And trying to cross-compile the Rust project the usual way (it already correctly bundles with
gtk-rs
and various other crates), using MinGW64 as a compilation backend, using the following commands on Ubuntu 20.04 LTS:libtextstyle
compiles with various warnings, but ultimatelygettext-sys
stops building with a linker error:Do you have any ideas of the possible cause of the issue, or need other details if helpful to troubleshoot it?
Regards,