neon icon indicating copy to clipboard operation
neon copied to clipboard

Fix mingw cross-builds

Open jimklimov opened this issue 2 years ago • 4 comments

While preparing a cross-build procedure (to compile NUT for Windows on a Linux machine with mingw) recently, I've been stuck with inability to build libneon on such platform out of the box. And also not on MSYS2 (a MinGW environment bundle for native Windows).

Looking around, I found a concise set of fixes among OBS recipes at https://build.opensuse.org/package/show/windows:mingw:win32/mingw32-libneon which got me started on this PR (with some creative adaptation).

Now I can configure and build neon on both Windows MSYS2 and Linux mingw environments, and use it as a shared DLL library for NUT. The hack is a bit dirty (setting ne_cv_os_uname in certain conditions) but making a clean cross-build solution needs larger autoconf script changes toward that goal :)

Example Linux-mingw cross-build looks like this:

./configure --prefix=/usr/i686-w64-mingw32 --host=i686-w64-mingw32 PKG_CONFIG_PATH=/usr/i686-w64-mingw32/lib/pkgconfig

For MSYS2 a plain ./configure should now suffice for the native target.

Prerequisites like libxml2 should be built and installed first, but were trivial to do so :)

Also note that to sudo make install from Git sources, I must make all docs explicitly first (otherwise it fails to install manpages), and that libtool installs "executable" MinGW DLL files like libneon-27.dll here into "bin", e.g. /usr/i686-w64-mingw32/bin location. The libneon.dll.a (hmmm) and neon.pc are provided to help build against it.

jimklimov avatar Aug 08 '22 14:08 jimklimov

Also note that to sudo make install from Git sources, I must make all docs explicitly first (otherwise it fails to install manpages),

https://github.com/notroj/neon/pull/34 https://github.com/notroj/neon/issues/67 https://github.com/notroj/neon/pull/69

That is intentional

1480c1 avatar Aug 08 '22 16:08 1480c1

Fair enough, comments in Makefile say as much. Although this nukes a common make all && sudo make install mantra (from git checkout) even where tools are available. I think this should be driven by configure script (NUT does so, and it is rather complicated) but that's up to projects of course.

jimklimov avatar Aug 08 '22 20:08 jimklimov

I locally just apply https://github.com/notroj/neon/pull/69.patch and keep my configure && make install wrappers intact, and it's been fine so far

1480c1 avatar Aug 08 '22 20:08 1480c1

Thanks for the heads-up :)

As for this PR, its focus was to make libneon cross-buildable (again?) and as I stumbled on installing the result, I posted a note of it. I know first-hand about googling for obscure solutions to non-core issues one gets in daily work - so your further references and context explanations are certainly helpful for such posterity :)

jimklimov avatar Aug 09 '22 07:08 jimklimov

Gentle bump to maintainer :)

jimklimov avatar Oct 02 '22 08:10 jimklimov

@jimklimov I posted a review question above a while ago, can you respond?

notroj avatar Oct 03 '22 07:10 notroj

@notroj : that's odd - do not see any in github :\ did you submit the review?

jimklimov avatar Oct 03 '22 08:10 jimklimov

Oh, it was visible to me but maybe not submitted, sorry. Is that visible now?

notroj avatar Oct 03 '22 08:10 notroj

Posted probable fixes, at least it still cross-builds for me from Linux and MSYS2 :) Now it also defines HAVE_WSPIAPI_H in generated config.h (although it seems the builds went fine without it too on both platforms).

jimklimov avatar Oct 03 '22 12:10 jimklimov

Thanks a lot @jimklimov! Sorry for leaving this hanging, I've not used the github review process much before.

notroj avatar Oct 05 '22 08:10 notroj