Description of problem:
libvirt currently fails to build for 64-bit Windows because of missing index() function. First it produces a warning:
--- cut ---
util/virstring.c:1006:9: warning: implicit declaration of function 'index' [-Wimplicit-function-declaration]
if (index(control_chars, str[i]))
--- cut ---
but when linking it fails with "undefined symbol" error. MinGW's libc does not have deprecated index() and rindex(). The solution is to replace index() with strchr().
Version-Release number of selected component (if applicable):
configure and build it natively under MinGW64
Fixed upstream. For issues like this, proposing the (obvious) patch to email@example.com is faster (and less hoops to jump through) than opening up a bug report, especially when the bug only affects git builds and not a released tarball.
Author: Eric Blake <firstname.lastname@example.org>
Date: Thu Apr 23 08:13:53 2015 -0600
build: avoid obsolete index()
Commit 2a530a3e5 is not portable to mingw, which intentionally
avoids declaring the obsolete index(). See also:
* src/util/virstring.c (virStringStripControlChars): Use strchr.
Signed-off-by: Eric Blake <email@example.com>
I decided to reopen it because there is additional problem affecting MinGW build. LDFLAGS definitions for all shared libraries in tests/Makefile.am miss $(MINGW_EXTRA_LDFLAGS) addon, and virnetserverclientmock_la_LDFLAGS needs also $(GNULIB_LIBS).
MINGW_EXTRA_LDFLAGS specified -no-undefined, without which building shared library fails on MinGW. The later explicitly adds gnulib, this is necessary because .dll module on Windows has to be self-contained, it cannot import anything from the executable which is importing the dll (without special tricks).
Sorry, i cannot post patches, because i am reporting from my workplace, and according to regulations of our company i need an explicit approval to post patches. Currently it is being processed, and it can take a long time. Much longer than fixing the bug as described (reporting and discussion is OK here).
Normally, I'd suggest that you use a separate bug for separate issues. But reopening is probably okay here.
Meanwhile, let me reiterate that since the issue you are seeing affects the latest libvirt.git, you'll probably get faster response by posting on the upstream firstname.lastname@example.org mailing list than you will by making a BZ.
This should be fixed upstream by commits v1.2.14-324-g9dc57ce and v1.2.15-rc1-16-g922563e:
Author: Pavel Fedin <email@example.com>
AuthorDate: Mon Apr 27 13:40:53 2015 +0300
Add missing linker flags for MinGW build
Author: Martin Kletzander <firstname.lastname@example.org>
Date: Mon Apr 27 15:59:18 2015 +0200
Fix building virnetserverclientmock with MinGW